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

  1. // ==UserScript==
  2. // @name Replace Alienware Arena Control Center Twitch links
  3. // @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
  4. // @author floriegl
  5. // @license CC0
  6. // @match https://*.alienwarearena.com/control-center
  7. // @icon https://media.alienwarearena.com/images/favicons/favicon.ico
  8. // @version 1.0
  9. // @grant GM_addStyle
  10. // @run-at document-start
  11. // @namespace https://greasyfork.org/users/703184
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. let css = `
  16. .user-profile__profile-card:has( > .user-profile__card-header #control-center__twitch-max-reached) .quest-list__play {
  17. display: none;
  18. }
  19. .user-profile__profile-card:has( > .user-profile__card-header #control-center__twitch-max-reached) .converted > .quest-list__play {
  20. display: inline-block;
  21. }
  22. `;
  23. if (typeof GM_addStyle !== "undefined") {
  24. GM_addStyle(css);
  25. } else {
  26. let styleNode = document.createElement("style");
  27. styleNode.appendChild(document.createTextNode(css));
  28. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  29. }
  30. let x = 0;
  31. const intervalID = setInterval(function () {
  32. const foundLinks = document.querySelectorAll(".user-profile__profile-card:has( > .user-profile__card-header #control-center__twitch-max-reached) a:has( > .quest-list__play)");
  33. if (foundLinks.length) {
  34. window.clearInterval(intervalID);
  35. for (const foundLink of foundLinks) {
  36. const convertedLink = (foundLink.href.match(/(?:https?:\/\/)?(?:www\.)?twitch\.tv\/([^\/?]+)/) || [])[1];
  37. if (convertedLink != null) {
  38. foundLink.href = "https://www.twitch.tv/popout/" + convertedLink + "/extensions/ehc5ey5g9hoehi8ys54lr6eknomqgr/panel";
  39. foundLink.classList.add("converted");
  40. }
  41. }
  42. }
  43. if (++x === 20) {
  44. window.clearInterval(intervalID);
  45. }
  46. }, 500);
  47. })();