Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name tiktok.com Not-Found landing page restore initial URL
- // @namespace https://greasyfork.org/en/users/85671-jcunews
- // @version 1.0.1
- // @license AGPL v3
- // @author jcunews
- // @description Context: https://www.reddit.com/r/userscripts/comments/11m0a61/can_someone_make_a_simple_script_that_doesnt_let/
- // @match *://*/*
- // @include *:*
- // @grant GM_getValue
- // @grant GM_setValue
- // @run-at document-start
- // ==/UserScript==
- /*
- Notes:
- - Only work when clicking a true HTML link with URL. i.e. will not work for fake links, buttons, JavaScript driven links,
- web browser bookmark, or if an URL is entered into browser addressbar.
- - May sometimes not work if the link is on a page presented within an IFRAME. This is due to a bug in the GM provider browser
- extension (i.e. TamperMonkey, ViolentMonkey, etc.) where scripts may or may not run on page presented within an IFRAME.
- */
- (url => {
- if (location.hostname === "www.tiktok.com") {
- if (/:\/\/www\.tiktok\.com\/notfound/.test(location.href) && (url = GM_getValue("url", ""))) addEventListener("load", () => history.pushState({}, "", url));
- addEventListener("load", () => {
- setTimeout(() => GM_setValue("url", ""), 2000)
- })
- }
- addEventListener("mousedown", e => {
- if ((e = e.target).closest && (e = e.closest("a")) && /^(www\.)tiktok\.com$/.test(e.hostname)) GM_setValue("url", e.href)
- }, true)
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement