Play multiple replays

plays a sequence of replays back to back

目前為 2019-06-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Play multiple replays
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  plays a sequence of replays back to back
// @author       Oki
// @match        https://*.jstris.jezevec10.com/*
// @grant        none
// ==/UserScript==

/**************************
  Jstris Stats Script         
**************************/

//Set the sequence of replays to be played by pasting them
//into the console like shown below (do this before playing any replays)
//Start by manually opening the first link in this list

//localStorage.playReplays = [
//"https://jstris.jezevec10.com/replay/1v1/N9SEV2?u=ajanba",
//"https://jstris.jezevec10.com/replay/1v1/ENECQZ?u=ajanba",
//"https://jstris.jezevec10.com/replay/1v1/O7IO86?u=ajanba",
//"https://jstris.jezevec10.com/replay/1v1/LB90ZQ?u=ajanba"
//]

var delayBeforeClickingLoad = 2000;
var delayAfterReplayFinishes = 2000;

(function() {

    window.addEventListener('load', function(){

    	setTimeout(startReplay,delayBeforeClickingLoad)

    	function startReplay() {
    		if(typeof load != "undefined"){
				localStorage.playReplays = localStorage.playReplays.split(",").slice(1)
				load.click()
				setTimeout(overwrite,2000)
			}
    	}
		
		var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
		var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
		
		function overwrite() {
			var paint = View['prototype']['paintMatrixWithColor'].toString()
			var paintParams = getParams(paint);
			paint = `setTimeout(x=>{location.replace(localStorage.playReplays.split(",")[0])},${delayAfterReplayFinishes});` + trim(paint)
			View['prototype']['paintMatrixWithColor'] = new Function(...paintParams, paint);
		}
    });
})();