-
Notifications
You must be signed in to change notification settings - Fork 11
/
script.min.js
2 lines (2 loc) · 4.22 KB
/
script.min.js
1
2
var scriptOptions={scrolling_min_time:1300,scrolling_max_time:2100,min_views:-1,delete_from_next_txt:!0,output_name_type:2,adapt_text_output:!0,allow_images:!0,advanced:{get_array_after_scroll:!1,get_link_by_filter:!0,check_nullish_link:!0,log_link_error:!0,maximum_downloads:1/0},node:{resolve:null,isNode:!1,isResolveTime:!1}};function nodeElaborateCustomArgs(e){""!==(e??"")&&e.forEach(e=>{var t=e[0].split("=>");1===t.length?scriptOptions[e[0]]=e[1]:scriptOptions[t[0]][t[1]]=e[1]})}var height=document.body.scrollHeight,containerSets=[[],[]],skipLinks=[];function loadWebpage(){0===document.querySelectorAll(".tiktok-qmnyxf-SvgContainer").length?(window.scrollTo({top:document.body.scrollHeight,behavior:"smooth"}),setTimeout(()=>{height!==document.body.scrollHeight?!scriptOptions.advanced.get_array_after_scroll&&(addArray(),scriptOptions.advanced.maximum_downloads<containerSets[0].length+skipLinks.length)?ytDlpScript():setTimeout(()=>{height=document.body.scrollHeight,loadWebpage()},Math.floor(Math.random()*scriptOptions.scrolling_max_time+scriptOptions.scrolling_min_time)):setTimeout(()=>{(0===document.querySelectorAll(".tiktok-qmnyxf-SvgContainer").length&&height==document.body.scrollHeight?(scriptOptions.node.isResolveTime=!0,ytDlpScript):loadWebpage)()},3500)},150)):setTimeout(function(){loadWebpage()},1e3)}function addArray(){for(var e,t=document.querySelectorAll(".tiktok-x6y88p-DivItemContainerV2, .css-x6y88p-DivItemContainerV2, .css-1soki6-DivItemContainerForSearch"),i=0;i<t.length;i++)t[i]&&(e=(scriptOptions.advanced.get_link_by_filter?Array.from(t[i].querySelectorAll("a")).filter(e=>-1!==e.href.indexOf("/video/")||-1!==e.href.indexOf("/photo/"))[0]:t[i].querySelector("[data-e2e=user-post-item-desc], [data-e2e=user-liked-item], [data-e2e=music-item], [data-e2e=user-post-item], [data-e2e=favorites-item], [data-e2e=challenge-item], [data-e2e=search_top-item]")?.querySelector("a"))?.href,!scriptOptions.allow_images&&-1!==e.indexOf("/photo/")||(scriptOptions.advanced.check_nullish_link&&""===(e??"")?scriptOptions.advanced.log_link_error&&console.log("SCRIPT ERROR: Failed to get link!"):-1===containerSets[0].indexOf(e)&&-1===skipLinks.indexOf(e)&&(containerSets[0].push(e),containerSets[1].push((t[i].querySelector("[data-e2e=video-views]")?.innerHTML??"0").replace("K","00").replace("M","00000")))))}function sanitizeName(e){return e.replaceAll("<","‹").replaceAll(">","›").replaceAll(":","∶").replaceAll('"',"″").replaceAll("/","∕").replaceAll("\\","∖").replaceAll("|","¦").replaceAll("?","¿").replaceAll("*","")}function ytDlpScript(){addArray();for(var e="",t=0;t<containerSets[0].length;t++)parseInt(containerSets[1][t])<scriptOptions.min_views||(e+=containerSets[0][t]+`
`);if(scriptOptions.node.isNode&&!scriptOptions.node.isResolveTime)return e.split("\n");downloadScript(e)}function downloadScript(e){if(scriptOptions.node.isNode)return scriptOptions.node.isResolveTime?void scriptOptions.node.resolve(e.split("\n")):e.split("\n");var e=new Blob([e],{type:"text/plain"}),t=document.createElement("a"),i="TikTokLinks.txt";switch(scriptOptions.output_name_type){case 0:i=document.querySelector("[data-e2e=user-title]")?.textContent.trim()??document.querySelector("[data-e2e=browse-username]")?.firstChild?.textContent.trim()??document.querySelector("[data-e2e=browse-username]")?.textContent.trim()??document.querySelector("[data-e2e=challenge-title]")?.textContent.trim()??document.querySelector("[data-e2e=music-title]")?.textContent.trim()??"TikTokLinks.txt";break;case 1:i=document.title.substring(0,document.title.indexOf(" | TikTok"))+".txt";break;case 2:i=`${document.querySelector("h1")?.textContent.trim()??"TikTokLinks"}.txt`}"string"==typeof scriptOptions.output_name_type&&(i=scriptOptions.output_name_type),scriptOptions.adapt_text_output&&(i=sanitizeName(i)),t.href=URL.createObjectURL(new File([e],i,{type:"text/plain"})),t.download=i,t.click(),URL.revokeObjectURL(t.href)}function requestTxtNow(){var e=ytDlpScript();return scriptOptions.delete_from_next_txt&&(skipLinks.push(...containerSets[0]),containerSets=[[],[]]),e}function startDownload(e){if(""!==(e??"")&&(scriptOptions.output_name_type=e),scriptOptions.node.isNode)return new Promise(e=>{scriptOptions.node.resolve=e,loadWebpage()});loadWebpage()}nodeElaborateCustomArgs(),startDownload();