您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Redirect Twitch with options
当前为
// ==UserScript== // @name Twitch Multi-Redirect // @namespace RexOmni // @version 1.0 // @description Redirect Twitch with options // @author RexOmniFurtim // @match https://www.twitch.tv/* // @exclude https://www.twitch.tv/ // @exclude https://www.twitch.tv/directory/* // @grant GM_getValue // @grant GM_setValue // @run-at document-idle // @noframes // ==/UserScript== (function() { 'use strict'; /////////// // SETUP // /////////// var tmr = new Object(); tmr.intervals = []; tmr.elements = []; tmr.options = [ 'TwitchLS', 'Multitwitch' ]; tmr.redirects = { // Redirect functions 'twitchls' : function(){ window.location.replace('http://twitchls.com/' + tmr.channel); }, 'multitwitch' : function(){ window.location.replace('http://multitwitch.tv/' + tmr.channel); } }; tmr.settings = new Object(); // load settings tmr.settings.redirectTarget = GM_getValue("tmr-redirectTarget", 'twitchls'); tmr.settings.redirectTimer = GM_getValue("tmr-redirectTimer", '850'); tmr.channel = window.location.pathname.substring(1, window.location.pathname.length); console.log('%c' + tmr.channel, 'background: #3333ff; color: #fff; font-size: 22px;'); //////////// // CREATE // //////////// // create and add div tmr.elements.container = document.createElement('div'); tmr.elements.container.innerHTML = '<div style="width:100%;height:100%;position:absolute;background:rgba(255,0,0,0.5);z-index:99999;text-align:center;cursor:pointer;"><div style="background:white;padding: 2rem;margin: 2rem;"><p style="font-size:6rem;">Twitch Multi-Redirect</p><hr style="margin-top: 3rem;"> <div id="TMR-Warning" style="margin-top:2rem;display:block;"><p style=" font-size: 2rem; background: rgba(0,0,255,.4); padding-bottom: 0.5rem;">Click anywhere to stop redirecting</p></div> <div id="TMR-Settings" style="margin-top:2rem;display:none"><p style="font-size:4rem;background:rgba(0,125,125,.5);padding-bottom:2rem;padding-top:1rem;">Settings</p><div style="width: 100%;margin-top: 2rem;"> <span style="padding-right:.7rem">Redirection target</span><select id="TMR-Select"></select><br><br><input id="TMR-Savebtn" type="button" value="Save"></div></div></div></div>'; document.body.insertBefore(tmr.elements.container, document.body.firstChild); tmr.elements.warning = document.getElementById("TMR-Warning"); tmr.elements.settings = document.getElementById("TMR-Settings"); tmr.elements.select = document.getElementById("TMR-Select"); tmr.elements.savebtn = document.getElementById('TMR-Savebtn'); // populate the drop-down, select var numOptions = tmr.options.length; for (var i = 0; i < numOptions; i++) { var option = document.createElement("option"); option.text = tmr.options[i]; option.value = tmr.options[i].toLowerCase(); tmr.elements.select.add(option); } // save the selection tmr.elements.savebtn.onclick = function(){ //save the data GM_setValue("twitchmultiredirect", tmr.elements.select.options[tmr.elements.select.selectedIndex].value); tmr.elements.container.style.display = 'none'; }; // on click anywhere stop redirect tmr.elements.container.onclick = function(){ tmr.elements.container.onclick = null; console.log('%cStopping Redirect', 'background: #3333ff; color: #fff; font-size: 22px;'); clearTimeout(tmr.intervals.redirect); tmr.elements.warning.style.display = 'none'; tmr.elements.container.style.display = 'none'; tmr.elements.settings.style.display = 'block'; tmr.intervals.gear = setInterval(addGear, 250); }; // Interval tmr.intervals.redirect = setTimeout(function(){ if (shouldRedirect() ){ // if the redirect target function is found is found if( tmr.redirects[tmr.settings.redirectTarget] !== null ){ tmr.redirects[tmr.settings.redirectTarget](); } else{ console.log("TMR: redirection target funciton not found"); tmr.elements.container.click(); } } // shouldRedirect else{ tmr.elements.container.click(); } }, tmr.settings.redirectTimer); // Check to see whether the redirect param is set to false function shouldRedirect(){ var pathArray = /redirect=([^&]+)/.exec(window.location.href); if (pathArray === null){ return true; } var param = pathArray[1]; var result = param ? param : 'false'; if (result == 'false'){ return false; } return true; } // add the gear when the hcat popup is available function addGear(){ var chatpopup = document.getElementsByClassName('js-chat-settings chat-settings chat-menu dropmenu'); // if chat popup is found if (chatpopup.length > 0){ clearInterval(tmr.intervals.gear); tmr.elements.gear = document.createElement('div'); tmr.elements.gear.innerHTML = '<div style="cursor:pointer;background: rgba(237,237,237,0.7);padding: 0.5rem 10rem 0.2rem 1.3rem;"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURQAAADAwMDg4ODAwMC8vLzAwMDMzMzAwMDAwMDMzM5MpzFMAAAAJdFJOUwAEAeiXxSFuRDq7DUMAAAX9SURBVHja3V3r0uQoCI0oat7/hdeYvqS/joZLR5n1x9RU7SZ9AhxEQGZZ9AuWnEJAv+7Le48YQsrlP9hYsOB6shCMIITF+TOAPpoBGNfTZUXHbsktgM4IwHQOMJkBGM4BBiMAGyQuNLZhg4Uj/hygdyYQNjmyrtEIwNQCaIPGTY5YoXGTI0Zo3NroaDQG7RdAWcKNjkLj8nIAHT7nLtTUIfFluFDenVWuqLwAsfwBMhJf0LioN+IanNxQ6wtWn7sIOyTu07i8tH4aRiHC8oF5N/8A7VcU6NgG2KbxLr7dEPoS6OB76W77SOBudDuNXVN82R8FDRp85SNTwyFAjyNb1A9nP12ecuGPKQAb36dphROubD/e5chO4y+Mn+J72gKo8H1bSv1ZiAk7Gi5PYYrl/3OHR7/EJ0AIp9Q8qrn+raBbCatgXN5idO5LfGyE0HAdL65U3dLQPZ7c/HEV+an4uBt307Vtat5/KQa/sham+mARnz606Nn9zpUYVv7yBWKR+ypz69S9qyhLBm9XQOybBSnAha5jK7/CVS5nEY76/Z3h7kXIlsCC68R1TZS+Bd6+SDoO8/BReDzTCGme0F3QeCpFrmPkew2QtpWUfRbtKniekpFxAJ2hZFZGe4aSeYmm8UrmpnFGbyjITjAADFUy//A+dkORJBJHKlmWRxwXeAmT7eOULE1lj/I14kx2L7k73wJH0kSo4nE2iDKSDIwYRFbYy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7Gb0UTs+zvecLBcGMuvfgrXodQ1h6vEiOP1xiko4uqxoI8eLxXgB5lRSqXJHhe1Z70+UQw+6MJML8GCcfQVgQxuuv651hCJsXaEYkAtAGwPysgCRBqMnEGpn43D7nG5mZ3aaxkXHFbRonKwDzLI5oAUbjA5+NzHtu36VFK5P5W+GClZnjTT+T7ABMDRKbUXG2zJEmjdHQv17hvGWO1A4MX9ZTtY9//+Mnbvo/TV/m1yK+SaAAAAAASUVORK5CYII=" style=" width: 15%;"> <span style="">TMR Settings</span> </div>'; chatpopup[0].insertBefore(tmr.elements.gear, chatpopup[0].firstChild); // Gear onclick function; tmr.elements.gear.onclick = function(){ tmr.elements.container.style.display = 'block'; tmr.elements.select.selectedIndex = 0; }; } } console.log('%c AutotwitchLS loaded! ', 'background: #333; color: #fff; font-size: 2em;'); })();