{
  "version": "1.0.0",
  "exported_at": "2026-05-31T04:45:00.000Z",
  "project": {
    "name": "Twitter Advanced Search Scraper",
    "description": "Best-effort X/Twitter advanced search scraper for public/search-visible tweets. Extracts query, author, verification, timestamp, tweet text, tweet URL/ID, reply/repost/like/view/bookmark counts, media URLs, reply-to fields, language, and ad/promoted status. X search uses infinite scrolling, so this template auto-scrolls and collects all loaded tweets until results stabilize or a safety limit is reached. If X redirects to login/onboarding or hides tweets, the template still exports a diagnostic row in the same CSV schema instead of producing no file.",
    "color": "bg-[#1d9bf0]",
    "template_id": "ai-generated"
  },
  "blocks": [
    {
      "block_id": "set-window-size-1",
      "block_type": "process",
      "title": "Set Window Size",
      "description": "Set browser window dimensions",
      "position_x": 120,
      "position_y": 200,
      "config": {
        "width": 1920,
        "height": 1080,
        "color": "bg-[#4589ff]"
      }
    },
    {
      "block_id": "navigate-1",
      "block_type": "process",
      "title": "Navigate",
      "description": "Go to a URL",
      "position_x": 480,
      "position_y": 200,
      "config": {
        "url": "https://x.com/search?q=fringe&src=typed_query",
        "color": "bg-[#4589ff]"
      }
    },
    {
      "block_id": "wait-for-page-load-1",
      "block_type": "process",
      "title": "Wait for Page Load",
      "description": "Wait for page to finish loading",
      "position_x": 840,
      "position_y": 200,
      "config": {
        "timeout": 30,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "sleep-1",
      "block_type": "process",
      "title": "Sleep",
      "description": "Wait for specified time",
      "position_x": 1200,
      "position_y": 200,
      "config": {
        "duration": 5,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "inject-javascript-1",
      "block_type": "process",
      "title": "Inject JavaScript",
      "description": "Execute custom JavaScript",
      "position_x": 1560,
      "position_y": 200,
      "config": {
        "jsCode": "(async()=>{const sleep=ms=>new Promise(r=>setTimeout(r,ms));const abs=h=>{try{return new URL(h,location.origin).href}catch(e){return h||''}};const txt=e=>e?(e.innerText||e.textContent||'').trim():'';const attr=(e,n)=>e?e.getAttribute(n)||'':'';const count=el=>{const s=(attr(el,'aria-label')||txt(el)||'').replace(/,/g,'');const m=s.match(/([0-9.]+\\s*[KMBkmb]?)/);return m?m[1].replace(/\\s+/g,''):''};const query=()=>new URLSearchParams(location.search).get('q')||decodeURIComponent((location.href.match(/[?&]q=([^&]+)/)||[])[1]||'');const keys=['query_str','post_url','author_name','author_web_page_url','author_handle','verified_status','utc_time','ads','tweet_content','post_id','tweet_url','reply_count','repost_count','like_count','view_count','bookmark_count','tweet_image_url','replying_to','reply_to_whom','reply_to_whom_url','reply_to_whom_username','reply_to_whom_handle','language'];const extract=a=>{const status=Array.from(a.querySelectorAll('a[href*=status]')).find(x=>/\\/status\\/\\d+/.test(attr(x,'href')));const tweet_url=status?abs(attr(status,'href')):'';const post_id=(tweet_url.match(/\\/status\\/(\\d+)/)||[])[1]||'';const handle=(tweet_url.match(/x\\.com\\/([^/]+)\\/status/)||[])[1]||'';const user=a.querySelector('[data-testid=User-Name]');let author_name=txt(user).split('\\n').filter(v=>v&&!v.startsWith('@'))[0]||'';const author_handle=handle||(txt(user).match(/@([A-Za-z0-9_]+)/)||[])[1]||'';const tweetText=a.querySelector('[data-testid=tweetText]');const content=txt(tweetText);const reply_to=(content.match(/^@([A-Za-z0-9_]+)/)||[])[1]||'';const imgs=Array.from(a.querySelectorAll('img')).map(i=>attr(i,'src')).filter(src=>/pbs\\.twimg\\.com\\/(media|tweet_video_thumb)/.test(src)).join('|');const viewEl=Array.from(a.querySelectorAll('a,div,span')).find(e=>/views?/i.test(attr(e,'aria-label'))&&/analytics|status/.test(attr(e,'href')||''));return {query_str:query(),post_url:location.href,author_name,author_web_page_url:author_handle?'https://x.com/'+author_handle:'',author_handle,verified_status:String(!!a.querySelector('[data-testid=icon-verified],svg[aria-label*=Verified]')),utc_time:attr(a.querySelector('time'),'datetime'),ads:String(/Promoted/i.test(txt(a))),tweet_content:content,post_id,tweet_url,reply_count:count(a.querySelector('[data-testid=reply]')),repost_count:count(a.querySelector('[data-testid=retweet]')),like_count:count(a.querySelector('[data-testid=like]')),view_count:count(viewEl),bookmark_count:count(a.querySelector('[data-testid=bookmark]')),tweet_image_url:imgs,replying_to:String(!!reply_to),reply_to_whom:reply_to,reply_to_whom_url:reply_to?'https://x.com/'+reply_to:'',reply_to_whom_username:reply_to,reply_to_whom_handle:reply_to,language:attr(tweetText,'lang')}};const seen=new Map((window.__uscraperXTweets||[]).map(t=>[t.tweet_url||t.post_id||t.tweet_content,t]));let stable=0,last=-1;for(let i=0;i<80&&stable<6;i++){document.querySelectorAll('article[data-testid=tweet]').forEach(a=>{const t=extract(a);const k=t.tweet_url||t.post_id||t.tweet_content;if(k)seen.set(k,t)});if(seen.size===0&&i>=2&&/Happening now|Continue with|Log in|Sign up|redirect_after_login|this page doesn.t exist|Try searching/i.test(document.body.innerText+' '+location.href)){break}window.scrollBy(0,Math.max(window.innerHeight*0.9,700));await sleep(1400);if(seen.size===last)stable++;else stable=0;last=seen.size;if(/rate limit|something went wrong/i.test(document.body.innerText))break}document.querySelectorAll('article[data-testid=tweet]').forEach(a=>{const t=extract(a);const k=t.tweet_url||t.post_id||t.tweet_content;if(k)seen.set(k,t)});window.__uscraperXTweets=Array.from(seen.values());if(window.__uscraperXTweets.length===0){window.__uscraperXTweets=[{query_str:query(),post_url:location.href,author_name:'',author_web_page_url:'',author_handle:'',verified_status:'',utc_time:'',ads:'',tweet_content:'NO_TWEETS_VISIBLE_OR_LOGIN_REQUIRED: X did not expose tweet articles to this browser session. Use a logged-in UScraper browser profile or reduce rate limits and rerun.',post_id:'',tweet_url:'',reply_count:'',repost_count:'',like_count:'',view_count:'',bookmark_count:'',tweet_image_url:'',replying_to:'',reply_to_whom:'',reply_to_whom_url:'',reply_to_whom_username:'',reply_to_whom_handle:'',language:''}]}const old=document.getElementById('uscraper-x-tweet-cache');if(old)old.remove();const cache=document.createElement('div');cache.id='uscraper-x-tweet-cache';cache.style.display='none';window.__uscraperXTweets.forEach(t=>{const r=document.createElement('div');r.className='uscraper-x-tweet-row';keys.forEach(k=>r.setAttribute('data-'+k.replace(/_/g,'-'),t[k]||''));r.textContent=t.tweet_content||'';cache.appendChild(r)});document.body.appendChild(cache);return window.__uscraperXTweets.length;})()",
        "waitForCompletion": true,
        "timeout": 180,
        "color": "bg-[#a56eff]"
      }
    },
    {
      "block_id": "wait-for-element-1",
      "block_type": "process",
      "title": "Wait for Element",
      "description": "Wait until element appears",
      "position_x": 1920,
      "position_y": 200,
      "config": {
        "selector": "#uscraper-x-tweet-cache .uscraper-x-tweet-row",
        "timeout": 20,
        "visible": false,
        "color": "bg-[#08bdba]"
      }
    },
    {
      "block_id": "structured-export-1",
      "block_type": "process",
      "title": "Structured Export",
      "description": "Export data with custom columns",
      "position_x": 2280,
      "position_y": 200,
      "config": {
        "rowSelector": "#uscraper-x-tweet-cache .uscraper-x-tweet-row",
        "fileName": "twitter-scraper-by-keywords.csv",
        "saveLocation": "C:\\Users\\theskd\\Documents\\UScraper\\templates",
        "includeHeaders": true,
        "fileMode": "append",
        "color": "bg-[#42be65]",
        "columns": [
          {
            "name": "Query_Str",
            "selector": "",
            "attribute": "data-query-str"
          },
          {
            "name": "Post_URL",
            "selector": "",
            "attribute": "data-post-url"
          },
          {
            "name": "Author_Name",
            "selector": "",
            "attribute": "data-author-name"
          },
          {
            "name": "Author_Web_Page_URL",
            "selector": "",
            "attribute": "data-author-web-page-url"
          },
          {
            "name": "Author_Handle",
            "selector": "",
            "attribute": "data-author-handle"
          },
          {
            "name": "Verified_Status",
            "selector": "",
            "attribute": "data-verified-status"
          },
          {
            "name": "UTC_Time",
            "selector": "",
            "attribute": "data-utc-time"
          },
          {
            "name": "Ads",
            "selector": "",
            "attribute": "data-ads"
          },
          {
            "name": "Tweet_Content",
            "selector": "",
            "attribute": "data-tweet-content"
          },
          {
            "name": "Post_ID",
            "selector": "",
            "attribute": "data-post-id"
          },
          {
            "name": "Tweet_URL",
            "selector": "",
            "attribute": "data-tweet-url"
          },
          {
            "name": "Reply_Count",
            "selector": "",
            "attribute": "data-reply-count"
          },
          {
            "name": "Repost_Count",
            "selector": "",
            "attribute": "data-repost-count"
          },
          {
            "name": "Like_Count",
            "selector": "",
            "attribute": "data-like-count"
          },
          {
            "name": "View_Count",
            "selector": "",
            "attribute": "data-view-count"
          },
          {
            "name": "Bookmark_Count",
            "selector": "",
            "attribute": "data-bookmark-count"
          },
          {
            "name": "Tweet_Image_URL",
            "selector": "",
            "attribute": "data-tweet-image-url"
          },
          {
            "name": "Replying_to",
            "selector": "",
            "attribute": "data-replying-to"
          },
          {
            "name": "Reply_to_Whom",
            "selector": "",
            "attribute": "data-reply-to-whom"
          },
          {
            "name": "Reply_to_Whom_URL",
            "selector": "",
            "attribute": "data-reply-to-whom-url"
          },
          {
            "name": "Reply_to_Whom_Username",
            "selector": "",
            "attribute": "data-reply-to-whom-username"
          },
          {
            "name": "Reply_to_Whom_Handle",
            "selector": "",
            "attribute": "data-reply-to-whom-handle"
          },
          {
            "name": "Language",
            "selector": "",
            "attribute": "data-language"
          }
        ]
      }
    },
    {
      "block_id": "end-1",
      "block_type": "output",
      "title": "End",
      "description": "Terminate execution flow",
      "position_x": 2640,
      "position_y": 200,
      "config": {
        "color": "bg-[#8d8d8d]"
      }
    }
  ],
  "connections": [
    {
      "from_block_id": "set-window-size-1",
      "from_connector_id": "right",
      "to_block_id": "navigate-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "navigate-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-page-load-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-page-load-1",
      "from_connector_id": "right",
      "to_block_id": "sleep-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "sleep-1",
      "from_connector_id": "right",
      "to_block_id": "inject-javascript-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "inject-javascript-1",
      "from_connector_id": "right",
      "to_block_id": "wait-for-element-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "wait-for-element-1",
      "from_connector_id": "right",
      "to_block_id": "structured-export-1",
      "to_connector_id": "left"
    },
    {
      "from_block_id": "structured-export-1",
      "from_connector_id": "right",
      "to_block_id": "end-1",
      "to_connector_id": "left"
    }
  ],
  "canvas_elements": [
    {
      "id": "group-entry",
      "element_type": "group",
      "title": "Entry & Setup",
      "color": "#4589ff",
      "position_x": 48,
      "position_y": 96,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "set-window-size-1"
        ]
      }
    },
    {
      "id": "group-load",
      "element_type": "group",
      "title": "Page Load",
      "color": "#08bdba",
      "position_x": 408,
      "position_y": 96,
      "width": 1760,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "navigate-1",
          "wait-for-page-load-1",
          "sleep-1",
          "wait-for-element-1"
        ]
      }
    },
    {
      "id": "group-interaction",
      "element_type": "group",
      "title": "Interaction",
      "color": "#a56eff",
      "position_x": 1488,
      "position_y": 96,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "inject-javascript-1"
        ]
      }
    },
    {
      "id": "group-extract",
      "element_type": "group",
      "title": "Data Extraction",
      "color": "#42be65",
      "position_x": 2208,
      "position_y": 96,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "structured-export-1"
        ]
      }
    },
    {
      "id": "group-control",
      "element_type": "group",
      "title": "Control Flow",
      "color": "#8d8d8d",
      "position_x": 2568,
      "position_y": 96,
      "width": 380,
      "height": 296,
      "z_index": 20,
      "data": {
        "memberBlockIds": [
          "end-1"
        ]
      }
    },
    {
      "id": "note-overview",
      "element_type": "note",
      "title": "Overview",
      "content": "Best-effort X/Twitter advanced search scraper for public/search-visible tweets. Extracts query, author, verification, timestamp, tweet text, tweet URL/ID, reply/repost/like/view/bookmark counts, media URLs, reply-to fields, language, and ad/promoted status. X search uses infinite scrolling, so this template auto-scrolls and collects all loaded tweets until results stabilize or a safety limit is reached. If X redirects to login/onboarding or hides tweets, the template still exports a diagnostic row in the same CSV schema instead of producing no file.",
      "color": "#f1c21b",
      "position_x": 80,
      "position_y": 20,
      "width": 480,
      "height": 160,
      "z_index": 22,
      "data": {}
    },
    {
      "id": "note-block-inject-javascript-1",
      "element_type": "note",
      "title": "Note: Inject JavaScript",
      "content": "Runs custom JavaScript in the page: `(async()=>{const sleep=ms=>new Promise(r=>setTimeout(r,ms));const abs=h=>{try{return new URL(h,locat...` Verify in browser if results are empty.",
      "color": "#ee5396",
      "position_x": 1760,
      "position_y": 180,
      "width": 340,
      "height": 140,
      "z_index": 22,
      "data": {
        "block_id": "inject-javascript-1"
      }
    },
    {
      "id": "note-block-structured-export-1",
      "element_type": "note",
      "title": "Note: Structured Export",
      "content": "Extracts rows matching `#uscraper-x-tweet-cache .uscraper-x-tweet-row`. Confirm row count > 0 before running at scale.",
      "color": "#ee5396",
      "position_x": 2480,
      "position_y": 180,
      "width": 340,
      "height": 119,
      "z_index": 22,
      "data": {
        "block_id": "structured-export-1"
      }
    }
  ]
}