🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

QQ收藏链接重定向

将你引导至QQ收藏正确指向的链接

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         QQ收藏链接重定向
// @namespace    QQ收藏重定向
// @version      0.5
// @description  将你引导至QQ收藏正确指向的链接
// @author       You
// @match       https://sharechain.qq.com/*
// @match       https://c.pc.qq.com/*
// @grant        none
// @license       MIT
// ==/UserScript==

(function () {
    'use strict';

    // 获取当前页面URL
    const currentURL = new URL(window.location.href);
    // 检查是否为c.pc.qq.com页面
    if (currentURL.hostname === 'c.pc.qq.com') {
        // 获取当前页面URL中的重定向后的链接
        const redirectedURL = new URLSearchParams(currentURL.search).get('url');
        if (redirectedURL) {
            // 重定向到正确的页面
            window.location.href = decodeURIComponent(redirectedURL);
        }
    }

    var redirectUrl = "mqq.weiyun";
    // 获取所有链接
    var links = document.getElementsByTagName('a');

    // 使用异步方式处理链接
    async function processLinks() {
        for (var i = 0; i < links.length; i++) {
            await processLink(links[i]);
        }
    }

    // 处理单个链接
    async function processLink(link) {
        // 检查链接是否包含重定向链接
        if (link.href.includes(redirectUrl)) {
            // 获取重定向链接中的url参数值
            var urlParam = new URL(link.href).searchParams.get("url");

            // 将链接替换为重定向链接中的url参数值
            link.href = decodeURIComponent(urlParam);
        }
    }

    // 调用异步处理链接的函数
    processLinks();

    // 添加监听器以检测网页内容变化
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            // 在每次变动后重新处理链接
            processLinks();
        });
    });

    // 配置并启动观察器
    var observerConfig = {
        childList: true,
        subtree: true
    };
    observer.observe(document.body, observerConfig);
})();