Replace Alienware Arena Control Center Twitch links

Replaces the Twitch quest links to the Twitch Alienware extension link in the Alienware Arena Control Center Twitch to not require the Twitch stream to be loaded

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Replace Alienware Arena Control Center Twitch links
// @description Replaces the Twitch quest links to the Twitch Alienware extension link in the Alienware Arena Control Center Twitch to not require the Twitch stream to be loaded
// @author      floriegl
// @license     CC0
// @match       https://*.alienwarearena.com/control-center
// @icon        https://media.alienwarearena.com/images/favicons/favicon.ico
// @version     1.6
// @grant       GM_addStyle
// @run-at      document-start
// @namespace   https://greasyfork.org/users/703184
// ==/UserScript==

(function() {
const UPGRADED_USERNAMES = ['TrishaHershberger', 'Mactics', 'FooYa', 'REDinFamy', 'Yun0gaming', 'kesslive', 'Ohmwrecker', 'Lovinurstyle', 'Layria', 'brydraa', 'Squeex', 'DatModz', 'CaliforniaGurl', '3llebelle', 'Liz_XP', 'KateeBear', 'A1phaChino', 'hazeleyedchic', 'DJUnreal', 'Pobelter', 'Valkyrae', 'TheGeekEntry', 'BlaineThePainTV', 'NinjaPullsGaming', 'MoonlitCharlie', 'Wickerrman', 'AmethystLady', 'BLbeel', 'everlynix', 'DemShenaniganss', 'whateverbri', 'Pokey_Star', 'runJDrun', 'Takkundr', 'Ludwig', 'MaudeGarrett', 'GrazeStreams', 'MatthewSantoro', 'Symfuhny', 'No_Lollygaggin'];
const css = `
.user-profile__profile-card:has( > .user-profile__card-header #control-center__twitch-max-reached) .quest-list__play {
    display: none;
}
.user-profile__profile-card:has( > .user-profile__card-header #control-center__twitch-max-reached) .converted > .quest-list__play {
    display: inline-block;
}
`;
if (typeof GM_addStyle !== "undefined") {
    GM_addStyle(css);
} else {
    let styleNode = document.createElement("style");
    styleNode.appendChild(document.createTextNode(css));
    (document.querySelector("head") || document.documentElement).appendChild(styleNode);
}
let x = 0;
const intervalID = setInterval(function () {
    const foundLinks = document.querySelectorAll(".user-profile__profile-card:has( > .user-profile__card-header #control-center__twitch-max-reached) a:has( > .quest-list__play)");
    if (foundLinks.length) {
        window.clearInterval(intervalID);
        for (const foundLink of foundLinks) {
            const username = (foundLink.href.match(/(?:https?:\/\/)?(?:www\.)?twitch\.tv\/([^\/?]+)/) || [])[1];
            if (username != null && !UPGRADED_USERNAMES.includes(username)) {
                foundLink.href = "https://www.twitch.tv/popout/" + username + "/extensions/ehc5ey5g9hoehi8ys54lr6eknomqgr/panel";
                foundLink.classList.add("converted");
            }
        }
    }
   if (++x === 20) {
       window.clearInterval(intervalID);
   }
}, 500);
})();