/*globals $:false */ // ==UserScript== // @name HasRoot - Twitch clip history button // @namespace http://gtarp.hasroot.com/ // @version 0.3 // @description Add HasRoot history button to Twitch clips. This script will only add the button when clips are opened from the HasRoot clips page. // @author ScottishRambler // @match *://clips.twitch.tv/* // @match *://*.hasroot.com/clips.php* // @match *://*.hasroot.com/userScripts.php* // @icon http://gtarp.hasroot.com/favicon.ico // @exclude *://clips.twitch.tv/embed* // @require https://code.jquery.com/jquery-3.3.1.min.js // @grant none // ==/UserScript== var INJECT_ON_ALL_CLIPS = false; let hostName = window.location.hostname.toLowerCase(); if (hostName.indexOf("hasroot.com") > -1 || hostName.indexOf("testroot.com") > -1) { $(".hasRootClipsButtonNotification").remove(); $("#hasrootClipsScript").addClass("installed"); $.noConflict(); } else { $( document ).on( "DOMNodeInserted",function() { if (INJECT_ON_ALL_CLIPS || window.location.href.toLowerCase().indexOf("from=hasroot") > -1) { if ($(".hasRootHistoryButton").length == 0) { let ele = $(".clips-sidebar > div:last-of-type > div "); let slug = window.location.href; let endIndex = slug.indexOf("?"); if (endIndex == -1) { endIndex = slug.length; } slug = slug.substring(slug.lastIndexOf("/")+1,endIndex); console.log("Slug = " + slug); if (ele.length == 0) { console.log("could not find ele"); } else { $( document ).unbind("DOMNodeInserted"); ele.removeClass("tw-justify-content-end"); ele.css("justify-content", "space-between"); let html = '
' $(html).prependTo(ele); console.log("Added button to ele"); } } } }); }