Kirneh / Open Twitch Clip Page Button

// ==UserScript==
// @name         Open Twitch Clip Page Button
// @namespace    http://twitter.com/Kirnehx
// @homepageURL  http://twitter.com/Kirnehx
// @supportURL   https://openuserjs.org/scripts/Kirneh/Open_Twitch_Clip_Page_Button/issues
// @updateURL    https://openuserjs.org/meta/Kirneh/Open_Twitch_Clip_Page_Button.meta.js
// @downloadURL  https://openuserjs.org/install/Kirneh/Open_Twitch_Clip_Page_Button.user.js
// @version      0.2.1.1
// @description  Places a button on the new clip page to open the old clip page
// @author       Kirneh
// @match        https://www.twitch.tv/*
// @grant        none
// @license      MIT
// ==/UserScript==

// ==OpenUserJS==
// @author Kirneh
// ==/OpenUserJS==

let loadOpenButton = setInterval(() => {
  let url = window.location.pathname;
  if (/clip/.test(url) && !(/clips/.test(url))) {
    if (!document.querySelector('#openClipButton')) {
      let url = window.location.pathname;
      let path = "https://clips.twitch.tv/" + url.slice(url.search(/clip/i) + 5);
      let openButton = '<a class="tw-align-items-center tw-align-middle tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium tw-border-top-left-radius-medium tw-border-top-right-radius-medium tw-core-button tw-core-button--primary tw-inline-flex tw-interactive tw-justify-content-center tw-overflow-hidden tw-relative" target="_blank" id="openClipButton" style="margin-right: 10px; margin-left:10px" href="' + path + '"><div class="tw-align-items-center tw-core-button-label tw-core-button-label--icon tw-flex tw-flex-grow-0"><div class="tw-align-items-center tw-flex tw-mg-r-05"><div class="tw-align-items-center tw-core-button-icon tw-inline-flex"><div data-a-selector="tw-core-button-icon" class="tw-align-items-center tw-full-width tw-icon tw-icon--fill tw-inline-flex"><div class="tw-aspect tw-aspect--align-top"><div class="tw-aspect__spacer" style="padding-bottom: 100%;"></div><svg class="tw-icon__svg" width="100%" height="100%" version="1.1" viewBox="0 0 20 20" x="0px" y="0px"><g><path d="M6 8h5.293L5 14.293l1.414 1.414 6.293-6.293V15h2V6H6v2z"></path></g></svg></div></div></div></div><div data-a-target="tw-core-button-label-text" class="tw-flex-grow-0">Open Clip Page</div></div></a>';
      document.querySelectorAll(".channel-info-content")[0].childNodes[0].childNodes[0].childNodes[0].querySelector('.tw-mg-r-1').insertAdjacentHTML('beforebegin', openButton);
    }
  }
}, 1000);