Created
October 22, 2025 20:49
-
-
Save motebaya/4dd3ee1a6e3dc45a7820cebdb65db366 to your computer and use it in GitHub Desktop.
tired change tikotok privacy media one by one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name TIKOTOK TOK TOK | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-06-01 | |
| // @description tiktok content privacy change automation | |
| // @author github.com/motebaya | |
| // @match https://www.tiktok.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=tiktok.com | |
| // @grant GM_xmlhttpRequest | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // ==/UserScript== | |
| (function () { | |
| "use strict"; | |
| const md = document.createElement("div"); | |
| Object.assign(md.style, { | |
| position: "fixed", | |
| top: "100px", | |
| left: "100px", | |
| zIndex: 9999, | |
| padding: 0, | |
| background: "white", | |
| border: "2px solid #ccc", | |
| boxShadow: "0 4px 12px rgba(0,0,0,0.2)", | |
| width: "350px", | |
| height: "400px", | |
| borderRadius: "8px", | |
| fontFamily: "sans-serif", | |
| }); | |
| const user = /(@\w+)/.exec(location)[0]; | |
| let urls = GM_getValue("urls", []), | |
| i = GM_getValue("index", 0); | |
| md.innerHTML = ` | |
| <div class="hd" style="cursor:move;background:#38485a;color:#fff;padding:8px 12px;border-radius:8px 8px 0 0;font-weight:bold;">🛠️ Tikotok</div> | |
| <div style="padding:10px;color:#000"> | |
| <p>🙎🏻:<b>${user}</b></p> | |
| <p>📇:<b>${i}</b></p> | |
| <p>🏦:<b>${urls.length}</b></p> | |
| <button id="btn" style="border:2px solid #000;padding:5px 50px;margin-top:2px;font-size:13px;">Start!</button><br><br> | |
| <textarea id="log" style="width:100%;height:200px;border:2px solid #000;outline:none;"></textarea> | |
| </div>`; | |
| document.body.appendChild(md); | |
| const hd = md.querySelector(".hd"), | |
| btn = md.querySelector("#btn"), | |
| log = md.querySelector("#log"); | |
| let drag = 0, | |
| x, | |
| y; | |
| hd.onmousedown = (e) => { | |
| drag = 1; | |
| x = e.clientX - md.offsetLeft; | |
| y = e.clientY - md.offsetTop; | |
| document.body.style.userSelect = "none"; | |
| }; | |
| document.onmouseup = () => { | |
| drag = 0; | |
| document.body.style.userSelect = "auto"; | |
| }; | |
| document.onmousemove = (e) => { | |
| if (drag) { | |
| md.style.left = e.clientX - x + "px"; | |
| md.style.top = e.clientY - y + "px"; | |
| } | |
| }; | |
| window.addEventListener("load", async () => { | |
| if (!location.href.endsWith(user)) { | |
| log.value += `🐞Dispatching mouse event.\n`; | |
| await new Promise((r) => setTimeout(r, 1e3)); | |
| const el = document.querySelector('[data-e2e="video-setting"]'); | |
| if (el) el.dispatchEvent(new MouseEvent("mouseover", { bubbles: !0 })); | |
| else log.value += `⚠️Cannot find video setting element.\n`; | |
| const btnPriv = document.querySelector( | |
| 'li[data-e2e="video-privacy-settings"]>button' | |
| ); | |
| if (btnPriv) { | |
| log.value += `🐞Clicking privacy settings.\n`; | |
| btnPriv.click(); | |
| const opt = document.querySelector('[data-e2e="video-setting-choose"]'); | |
| if (opt) { | |
| log.value += `🐞Clicking privacy options.\n`; | |
| opt.click(); | |
| await new Promise((r) => setTimeout(r, 500)); | |
| const pub = [ | |
| ...opt.nextSibling.nextSibling.querySelectorAll("li"), | |
| ].find((e) => e.querySelector("p").textContent.trim() === "Everyone"); | |
| if (pub) { | |
| log.value += `🐞Setting to Public.\n`; | |
| pub.click(); | |
| log.value += `🐞Closing modal.\n`; | |
| document | |
| .querySelector('button[data-e2e="video-setting-down"]') | |
| .click(); | |
| await new Promise((r) => setTimeout(r, 500)); | |
| } | |
| } | |
| } | |
| i++; | |
| if (i < urls.length) { | |
| GM_setValue("index", i); | |
| log.value += `➡️Processing index ${i} of ${urls.length} urls.\n`; | |
| location = urls[i]; | |
| } else { | |
| log.value += `🎉All done! Processed ${urls.length} urls.\n`; | |
| GM_setValue("urls", []); | |
| GM_setValue("index", 0); | |
| } | |
| } | |
| }); | |
| btn.onclick = () => { | |
| btn.textContent = "Ok!"; | |
| if (!urls.length) { | |
| urls = [ | |
| ...document.querySelectorAll( | |
| '[class*="DivVideoFeedV2"]>[class*="DivItemContainerV2"] div[class*="DivWrapper"]:has(svg.private)' | |
| ), | |
| ].map((i) => i.querySelector("a").href); | |
| GM_setValue("urls", urls); | |
| GM_setValue("index", 0); | |
| log.value += `✅Found ${urls.length} private media urls.\n`; | |
| } else { | |
| if (location.href.endsWith(user)) location = urls[i]; | |
| log.value += `🔄Resuming from index ${i} of ${urls.length} urls.\n`; | |
| } | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment