From 0ddf2d11dd1f724559c399c07869c19ae58135d7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 31 May 2016 22:17:45 +0200 Subject: [PATCH] Made the button appear faster --- MLButton.user.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/MLButton.user.js b/MLButton.user.js index 1adf14f..fbbc45c 100644 --- a/MLButton.user.js +++ b/MLButton.user.js @@ -6,11 +6,31 @@ // @author NorbiPeti // @match https://www.youtube.com/ // @include http://www.youtube.com/* -// @include https://www.youtube.com/* +// @include https://www.twitch.tv/Monstercat* +// @include https://live.monstercat.com/* // @grant none // ==/UserScript== window.lasturl=""; +window.lasttitle=""; +window.addtries=0; + +function Add() { + var title=document.getElementById("eow-title").title; + if(window.location.href==window.lasturl) + return; + if(title==lasttitle && window.lasttries<10) + { + window.addtries++; + window.setTimeout(Add, 100); + return; + } + var cont=document.getElementById("watch7-subscription-container"); + if(cont===null) + return; + cont.innerHTML+=""; + window.lasturl=window.location.href; //TODO: Show Lyrics button +} function AddIfChanged() { @@ -22,15 +42,7 @@ function AddIfChanged() var cont=document.getElementById("watch7-subscription-container"); if(cont===null) return; - window.setTimeout(function() { //TODO: Check for video title change every 100 ms - if(window.location.href==window.lasturl) - return; - var cont=document.getElementById("watch7-subscription-container"); - if(cont===null) - return; - cont.innerHTML+=""; - window.lasturl=window.location.href; - }, 2000); //TODO: Detect page load finish + window.setTimeout(Add, 100); } //TODO: Add for every platform, not just YouTube (function() {