您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Replay-button on mainpage with the last 2 players
当前为
// ==UserScript== // @name Autodarts Replay-Button // @namespace http://tampermonkey.net/ // @version 0.11 // @description Replay-button on mainpage with the last 2 players // @author benebelter // @match https://play.autodarts.io/* // @icon https://www.google.com/s2/favicons?sz=64&domain=autodarts.io // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js // @license MIT // @grant GM.getValue // @grant GM.setValue // @grant GM_xmlhttpRequest // @require https://update.greasyfork.org/scripts/445697/1244619/Greasy%20Fork%20API.js // ==/UserScript== (function() { 'use strict'; $.urlParam = function(name){ var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); if (results==null){ return null; } else{ return results[1] || 0; } } var player1 = ''; var player2 = ''; var rematch = ''; var player_clicked = 0; var documenttitle = 'Autodarts '; var gamemode = ''; var startx01 = ''; var variante = ''; var firstto = ''; var gameconditions = ''; var account; // Load last players (async () => { player1 = await GM.getValue('player1'); player2 = await GM.getValue('player2'); gamemode = await GM.getValue('gamemode'); startx01 = await GM.getValue('startx01'); variante = await GM.getValue('variante'); firstto = await GM.getValue('firstto'); })(); console.log('P1: '+ player1); console.log('P2: '+ player2); setInterval(function() { //console.log('Rematch-Status: '+$.urlParam('rematch')); // Lobby autostart if($('button:contains("Open Lobby")').length != 0 && $.urlParam('rematch') != null) { rematch = $.urlParam('rematch'); $('button:contains("Open Lobby")').click(); } // add players and start game if( $('button:contains("Start")').length != 0 && player_clicked == 0 && rematch != 0) { setTimeout(function(){ account = $('.ad-ext-player-name').eq( 1 ).text(); $("[aria-label='Delete player']").click(); }, 100); setTimeout(function(){ $('button:contains("Join")').addClass("account css-1e89954"); $('.account').css('color', 'yellow') ; $('.account').text(account); }, 200); // Player 1 starts if(rematch == 1){ setTimeout(function(){ $('button:contains("'+player1+'")').click(); }, 400); setTimeout(function(){ $('button:contains("'+player2+'")').click(); }, 600); } // Player 2 starts if(rematch == 2){ setTimeout(function(){ $('button:contains("'+player2+'")').click(); }, 400); setTimeout(function(){ $('button:contains("'+player1+'")').click(); }, 600); } setTimeout(function(){ $('button:contains("Start")').click(); }, 1000); player_clicked = 1; } // add Rematch-button to mainpage if(player1 !='' && player2 !='' && $('#rematch_button').length == 0 && typeof(player1) !== "undefined" && player1 !== null && typeof(player2) !== "undefined" && player2 !== null ) { var gameconditions = startx01 + ' | ' +variante + ' | ' + firstto; $('.css-lw6pyq').first().prepend('<span style="font-size: 1.4em">REMATCH</span><span style="color: yellow;">'+gameconditions+'</span><a class="chakra-button css-hbk3el" id="rematch_button" href="/lobbies/new/x01?rematch=1" style=""><br /><span style=" font-size: 0.6em; text-align: center !important;">'+player1+'<br />vs<br />'+player2+'</span></a><a class="chakra-button css-hbk3el" id="rematch_button" href="/lobbies/new/x01?rematch=2" style=""><span style=" font-size: 0.6em; text-align: center !important;">'+player2+'<br />vs<br />'+player1+'</span></a>'); } /// read player-names if( $('button:contains("Abort")').length != 0 ) { // only on own match-page const players = new Array(); var count = 1; $( ".ad-ext-player-name" ).each(function() { console.log('Neuer Spieler: '+$(this).text()); players.push( $(this).text() ); // save players-settings if($(this).text() != ''){ (async () => { await GM.setValue("player"+count, $(this).text() ); })(); documenttitle += $(this).text() + " - "; count++; } }); // Save Gamemode: gamemode = $('#ad-ext-game-variant').text(); startx01 = $('.css-1eveppl').eq( 1 ).text(); variante = $('.css-1eveppl').eq( 2 ).text(); firstto = $('.css-1eveppl').eq( 3 ).text(); (async () => { await GM.setValue("gamemode" , gamemode ); await GM.setValue("startx01" , startx01 ); await GM.setValue("variante" , variante ); await GM.setValue("firstto" , firstto ); })(); } // Change document-title document.title = documenttitle.slice(0, -3); // Refresh Mainpage with new names console.log(window.location.href); if( window.location.href == 'https://play.autodarts.io/' || window.location.href == 'https://play.autodarts.io' ) { $( '#root' ).remove(); location.replace('https://play.autodarts.io?reloaded'); } },1000); // end-interval })();