Twitch remove referrer=raid

automatically remove ?referrer=raid from twitch urls

目前为 2021-02-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         Twitch remove referrer=raid
// @description  automatically remove ?referrer=raid from twitch urls
// @namespace    https://github.com/adrianmgg
// @version      2.0.0
// @author       amgg
// @license      WTFPL
// @compatible   chrome only browser i've tested this on
// @match        https://www.twitch.tv/*
// @match        https://www.twitch.tv
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

// i can't think of what to name this function right now
function doTheThing(url) {
    // doing it this way (referrer=raid without the ?) since this works when there are other url params
    if(url.includes("referrer=raid")) {
        document.location.href = url.replace("referrer=raid", "");
    }
}

const PUSHSTATE = unsafeWindow.history.pushState;
unsafeWindow.history.pushState = function(state, title, url) {
    // doing this in a try/catch and alerting for now so that i can debug stuff
    try { doTheThing(url); }
    catch(e) { alert("fuck"); debugger; }
    return PUSHSTATE.apply(this, arguments);
};

// just in case we were brought to the page directly rather than through pushstate
doTheThing(document.location.href);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址