TikTok to TikNot Redirect

Redirect TikTok to TikNot

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         TikTok to TikNot Redirect
// @author       Rust1667
// @description  Redirect TikTok to TikNot
// @match        https://www.tiktok.com/*
// @match        https://tiknot.netlify.app/*
// @run-at       document-start
// @version      1.2
// @grant        none
// @namespace https://greasyfork.org/users/980489
// ==/UserScript==

(function() {
    'use strict';

    // Get the current URL
    var currentUrl = decodeURIComponent(window.location.href);

    // Regular expression to match the TikTok URL pattern
    var tiktokRegex = /https:\/\/www\.tiktok\.com\/@.*\/video\/([0-9]+)/;

    // Extract the second * from the TikTok URL using regex
    var match = currentUrl.match(tiktokRegex);

    if (match && match[1]) {
        // Construct the new URL using the matched part of the original URL
        var redirectUrl = "https://tiknot.netlify.app/video/" + match[1];

        // Redirect the page to the new URL
        window.location.href = redirectUrl;
    }
})();