Autodarts_Caller

Another Autodarts-Caller

目前為 2024-02-10 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Autodarts_Caller
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Another Autodarts-Caller
// @author       benebelter
// @match        https://play.autodarts.io/matches/*
// @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
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

//////////////// CONFIG ////////////////////

    var triplesound = 0; // 0=off / 1=simple beep on / 2=Löwen-sound (Soft-tip) on => triple_sound if hitting a triple
    var boosound = 0; //  0=off / 1=on => crowd-boo if hitting a miss
    var server = 'http://autodarts.x10.mx/'; //  Server
    var caller = 'x'; //  caller: "russ_bray", "google" (select language in next line)
    var language = 'de'; // de=german / en=english (only if use google)

//////////////// CONFIG ////////////////////



    function soundGo(file, audio){
        if (audio === 1){
            const audio = new Audio(file);
              audio.play();   }
        }

    function getDarts(){
        var runde =  $('.css-1tw9fat').text().substring(1).split("/");
        var numItems = $('.css-1chp9v4').length ;
        var dartsgesamt = (runde[0]*3-3)+numItems;
        return  "<span style='font-size:0.5em;'>"+dartsgesamt+" Darts</span>" ;
        }


$(document).ready(function(){

var t1 = 0; var t2 = 0; var t3 = 0;
var m1 = 0; var m2 = 0; var m3 = 0;
var dotmp3 = '.mp3';
var called =  0 ;
var gameshot_status = 0;
var busted = 0;
var audio = 1;
var firstgameoncall = 0;







        if( caller == 'google') {
      //  if(triplesound == 2) {
      //      triplesound = 1;
      //  }
        dotmp3 = '';
        server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
        caller = '/';
    }


setInterval(function() {



    // Caller icon laden
    if(!$("#russbray").length) {

        //$( ".css-1m5ohpg" ).prepend( "<span id=\"russbray\" class=\"css-1xn1mdy\"><button type=\"submit\" id=\"mute\"><img style=\"height: 20px; width: 20px;\" src=\"https://asc-images.forward-publishing.io/2021/5/13/76d0a824-c5ca-409b-91ae-c69df96daccb.jpeg?auto=compress%2Cformat\"></button</span>" );
        $( ".css-1m5ohpg" ).prepend( "<span id=\"russbray\" class=\"css-1xn1mdy\"><button type=\"submit\" id=\"mute\">Caller</button</span>" );
        $(".css-1xn1mdy").first().css("background-color","green");
    }



var x = $(".css-1tq00ko").text();
var x0 = $(".css-1tq00ko:eq(0)").text(); // Scrore-Feld
var x1 = $(".css-1tq00ko:eq(1)").text(); // 1. Dart
var x2 = $(".css-1tq00ko:eq(2)").text(); // 2. Dart
var x3 = $(".css-1tq00ko:eq(3)").text(); // 3. Dart
var gameshot1 = $(".css-x3m75h").eq(0).text(); // Spieler 1
var gameshot2 = $(".css-x3m75h").eq(1).text(); // Spieler 2
var gameshot3 = $(".css-x3m75h").eq(2).text(); // Spieler 3
var gameshot4 = $(".css-x3m75h").eq(3).text(); // Spieler 4
var gameshot5 = $(".css-x3m75h").eq(4).text(); // Spieler 5
var gameshot6 = $(".css-x3m75h").eq(5).text(); // Spieler 6
   // console.log('P1: '+gameshot1 + '- P2: '+ gameshot2);

//// Bust-Ausgabe ////
if (x0 == 'BUST' && busted == 0) {
        soundGo(server+caller+"0"+dotmp3, audio);
        busted = 1;
    }

//// Gameshot-Ausgabe ////

        // Gameshot aktivieren
        $("button:contains('Undo'),button:contains('Next Leg'),button:contains('Finish'),button:contains('Start')").on( "click", function() {
            gameshot_status = 0;


             console.log('GAMESHOT Status 0 ');
        })

    if (  gameshot_status != 1 && (gameshot1 == "0" || gameshot2 == "0" || gameshot3 == "0"|| gameshot4 == "0"|| gameshot5 == "0"|| gameshot6 == "0")   ){
    gameshot_status = 1;
    //soundGo("http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q="+gameshot+"&dummysox.mp3", audio);
     soundGo(server+caller+"gameshot"+dotmp3, audio);
        if (gameshot1 == "0") {
            $(".css-x3m75h").eq(0).html(getDarts()); }
        if (gameshot2 == "0") {
            $(".css-x3m75h").eq(1).html(getDarts()); }
                if (gameshot3 == "0") {
            $(".css-x3m75h").eq(2).html(getDarts()); }
          if (gameshot4 == "0") {
            $(".css-x3m75h").eq(3).html(getDarts()); }
          if (gameshot5 == "0") {
            $(".css-x3m75h").eq(4).html(getDarts()); }
          if (gameshot6 == "0") {
            $(".css-x3m75h").eq(5).html(getDarts()); }

    console.log('GAMESHOT Status '+gameshot_status );
    }
   //// END Gameshot ////
 



    ///////////////////////////////////////////////// TRIPLE CALLER ///////////////////////////
    if(triplesound == 1) {
    // Triple 1st dart
    if ( x1.includes("T") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t1 = 1;

        soundGo( "http://autodarts.x10.mx/russ_bray/triple_beep.mp3", audio);


        }
    // Triple 2st dart
    if ( x2.includes("T") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t2 = 1;

        soundGo( "http://autodarts.x10.mx/russ_bray/triple_beep.mp3", audio);

        }

    // Triple 3rd dart
    if ( x3.includes("T") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t3 = 1;

        soundGo( "http://autodarts.x10.mx/russ_bray/triple_beep.mp3", audio);

        }
    }
///////////////////////////////////////////////// END TRIPLE CALLER ///////////////////////////

        ///////////////////////////////////////////////// TRIPLE CALLER E-Dart Löwen///////////////////////////
    if(triplesound == 2) {
    // Triple 20 1st dart
    if ( x1.includes("T20") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t1 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple20_old.wav", audio);
        }
    // Triple 19 1st dart
    if ( x1.includes("T19") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t1 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple19_old.wav", audio);
        }
    // Triple 18 1st dart
    if ( x1.includes("T18") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t1 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple18_old.wav", audio);
        }
    // Triple 17 1st dart
    if ( x1.includes("T17") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t1 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple17_old.wav", audio);
        }

        /// 2. Dart
    // Triple 20 1st dart
    if ( x2.includes("T20") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t2 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple20_old.wav", audio);
        }
    // Triple 19 1st dart
    if ( x2.includes("T19") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t2 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple19_old.wav", audio);
        }
    // Triple 18 1st dart
    if ( x2.includes("T18") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t2 = 1;
        soundGo(server+caller+"/SoundHwTriple18_old.wav", audio);
        }
    // Triple 17 1st dart
    if ( x2.includes("T17") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t2 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple17_old.wav", audio);
        }


        /// 3. Dart
    // Triple 20 1st dart
    if ( x3.includes("T20") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t3 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple20_old.wav", audio);
        }
    // Triple 19 1st dart
    if ( x3.includes("T19") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t3 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple19_old.wav", audio);
        }
    // Triple 18 1st dart
    if ( x3.includes("T18") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t3 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple18_old.wav", audio);
        }
    // Triple 17 1st dart
    if ( x3.includes("T17") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
        t3 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple17_old.wav", audio);
        }


    }


///////////////////////////////////////////////// Miss CALLER ///////////////////////////
if(boosound == 1){

    // miss 1st dart
    if ( x1.includes("M") && m1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0)
    {   m1 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/miss_1st_dart.mp3", audio);
    }
    // miss 2st dart
    if ( x2.includes("M") && m2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0)
    {   m2 = 1;
        soundGo("http://autodarts.x10.mx/russ_bray/miss_2nd_dart.mp3", audio);
    }

    // miss 3rd dart
    if ( x3.includes("M") && m3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0)
    {    m3 = 1;
         soundGo("http://autodarts.x10.mx/russ_bray/miss_3rd_dart.mp3", audio);
    }
}


    // Caller reset
     if( (x1 == '' || $(".css-1tq00ko:eq(3)").closest('div').attr('class') != 'css-rzdgh7') && called == 1) {
          called = 0; busted = 0;
     }


// Caller if 3rd Dart has score and called = 0
    if( $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0 && caller != 'x') {

     //add 00 to score
      //  if(x0 < 10) {x0 = "00"+x0;}
       // else if(x0 <100) { x0 = "0"+x0 ;}
           soundGo(server+caller+x0+dotmp3, audio);

        console.log('Caller Ausgabe!');
        called = 1;
        t1 = 0; t2 = 0; t3 = 0;
        m1 = 0; m2 = 0; m3 = 0;
    }







    // Caller-Select einfügen wenn noch nicht existiert
if($("#caller").length == 0) {

  $(".css-a6m3v9").append('<select id="caller" name="caller" class="css-1xbroe7" style="padding:5px 5px 5px 5px;"><option selected disabled>Caller</option><option value="x">OFF</option><option value="google_eng">Google engl.</option><option value="google_fr">Google fran.</option><option value="google_de">Google deutsch</option><option value="russ_bray">Caller RB</option></select>');
    $(document).on('change', '#caller', function(){
      caller = $("#caller").find(":selected").val();

        if(caller == 'russ_bray') {
            server = 'http://autodarts.x10.mx/';
            caller = 'russ_bray/';
            dotmp3 = '.mp3';
               $("#caller option[value='russ_bray']").prop('selected', true);
        }

        if(caller == 'google_eng') {
              dotmp3 = '';
              language = 'en';
              server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
              caller = '/';
            $("#caller option[value='google_eng']").prop('selected', true);

        }

        if(caller == 'google_de') {
              dotmp3 = '';
              language = 'de';
              server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
              caller = '/';
            $("#caller option[value='google_de']").prop('selected', true);
        }

        if(caller == 'google_fr') {
              dotmp3 = '';
              language = 'fr';
              server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
              caller = '/';
            $("#caller option[value='google_fr']").prop('selected', true);
        }
    })

        // Triple-Select
  $(".css-a6m3v9").append('<select id="triplesound" name="triplesound" class="css-1xbroe7" style="padding:5px;"><option selected disabled>Triple-Sound</option><option value="0">OFF</option><option value="1">Beep on</option><option value="2">Löwen (Softtip)</option></select>');
    $(document).on('change', '#triplesound', function(){
      triplesound = $("#triplesound").find(":selected").val();


    })


     // Boo-Select
  $(".css-a6m3v9").append('<select id="boosound" name="boosound" class="css-1xbroe7" style="padding:5px;"><option selected disabled>Boo-Sound</option><option value="1">ON</option><option value="0">OFF</option></select>');
    $(document).on('change', '#boosound', function(){
      boosound = $("#boosound").find(":selected").val();


    })

}


},200);



 

    });


})();