Autodarts_Caller

Another Autodarts-Caller

当前为 2024-02-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Autodarts_Caller
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Another Autodarts-Caller
  6. // @author benebelter
  7. // @match https://play.autodarts.io/matches/*
  8. // @match https://play.autodarts.io/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=autodarts.io
  10. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. //////////////// CONFIG ////////////////////
  19.  
  20. var triplesound = 0; // 0=off / 1=simple beep on / 2=Löwen-sound (Soft-tip) on => triple_sound if hitting a triple
  21. var boosound = 0; // 0=off / 1=on => crowd-boo if hitting a miss
  22. var server = 'http://autodarts.x10.mx/'; // Server
  23. var caller = 'x'; // caller: "russ_bray", "google" (select language in next line)
  24. var language = 'de'; // de=german / en=english (only if use google)
  25.  
  26. //////////////// CONFIG ////////////////////
  27.  
  28.  
  29.  
  30. function soundGo(file, audio){
  31. if (audio === 1){
  32. const audio = new Audio(file);
  33. audio.play(); }
  34. }
  35.  
  36. function getDarts(){
  37. var runde = $('.css-1tw9fat').text().substring(1).split("/");
  38. var numItems = $('.css-1chp9v4').length ;
  39. var dartsgesamt = (runde[0]*3-3)+numItems;
  40. return "<span style='font-size:0.5em;'>"+dartsgesamt+" Darts</span>" ;
  41. }
  42.  
  43.  
  44. $(document).ready(function(){
  45.  
  46. var t1 = 0; var t2 = 0; var t3 = 0;
  47. var m1 = 0; var m2 = 0; var m3 = 0;
  48. var dotmp3 = '.mp3';
  49. var called = 0 ;
  50. var gameshot_status = 0;
  51. var busted = 0;
  52. var audio = 1;
  53. var firstgameoncall = 0;
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. if( caller == 'google') {
  62. // if(triplesound == 2) {
  63. // triplesound = 1;
  64. // }
  65. dotmp3 = '';
  66. server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
  67. caller = '/';
  68. }
  69.  
  70.  
  71. setInterval(function() {
  72.  
  73.  
  74.  
  75. // Caller icon laden
  76. if(!$("#russbray").length) {
  77.  
  78. //$( ".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>" );
  79. $( ".css-1m5ohpg" ).prepend( "<span id=\"russbray\" class=\"css-1xn1mdy\"><button type=\"submit\" id=\"mute\">Caller</button</span>" );
  80. $(".css-1xn1mdy").first().css("background-color","green");
  81. }
  82.  
  83.  
  84.  
  85. var x = $(".css-1tq00ko").text();
  86. var x0 = $(".css-1tq00ko:eq(0)").text(); // Scrore-Feld
  87. var x1 = $(".css-1tq00ko:eq(1)").text(); // 1. Dart
  88. var x2 = $(".css-1tq00ko:eq(2)").text(); // 2. Dart
  89. var x3 = $(".css-1tq00ko:eq(3)").text(); // 3. Dart
  90. var gameshot1 = $(".css-x3m75h").eq(0).text(); // Spieler 1
  91. var gameshot2 = $(".css-x3m75h").eq(1).text(); // Spieler 2
  92. var gameshot3 = $(".css-x3m75h").eq(2).text(); // Spieler 3
  93. var gameshot4 = $(".css-x3m75h").eq(3).text(); // Spieler 4
  94. var gameshot5 = $(".css-x3m75h").eq(4).text(); // Spieler 5
  95. var gameshot6 = $(".css-x3m75h").eq(5).text(); // Spieler 6
  96. // console.log('P1: '+gameshot1 + '- P2: '+ gameshot2);
  97.  
  98. //// Bust-Ausgabe ////
  99. if (x0 == 'BUST' && busted == 0) {
  100. soundGo(server+caller+"0"+dotmp3, audio);
  101. busted = 1;
  102. }
  103.  
  104. //// Gameshot-Ausgabe ////
  105.  
  106. // Gameshot aktivieren
  107. $("button:contains('Undo'),button:contains('Next Leg'),button:contains('Finish'),button:contains('Start')").on( "click", function() {
  108. gameshot_status = 0;
  109.  
  110.  
  111. console.log('GAMESHOT Status 0 ');
  112. })
  113.  
  114. if ( gameshot_status != 1 && (gameshot1 == "0" || gameshot2 == "0" || gameshot3 == "0"|| gameshot4 == "0"|| gameshot5 == "0"|| gameshot6 == "0") ){
  115. gameshot_status = 1;
  116. //soundGo("http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q="+gameshot+"&dummysox.mp3", audio);
  117. soundGo(server+caller+"gameshot"+dotmp3, audio);
  118. if (gameshot1 == "0") {
  119. $(".css-x3m75h").eq(0).html(getDarts()); }
  120. if (gameshot2 == "0") {
  121. $(".css-x3m75h").eq(1).html(getDarts()); }
  122. if (gameshot3 == "0") {
  123. $(".css-x3m75h").eq(2).html(getDarts()); }
  124. if (gameshot4 == "0") {
  125. $(".css-x3m75h").eq(3).html(getDarts()); }
  126. if (gameshot5 == "0") {
  127. $(".css-x3m75h").eq(4).html(getDarts()); }
  128. if (gameshot6 == "0") {
  129. $(".css-x3m75h").eq(5).html(getDarts()); }
  130.  
  131. console.log('GAMESHOT Status '+gameshot_status );
  132. }
  133. //// END Gameshot ////
  134.  
  135.  
  136.  
  137. ///////////////////////////////////////////////// TRIPLE CALLER ///////////////////////////
  138. if(triplesound == 1) {
  139. // Triple 1st dart
  140. if ( x1.includes("T") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  141. t1 = 1;
  142.  
  143. soundGo( "http://autodarts.x10.mx/russ_bray/triple_beep.mp3", audio);
  144.  
  145.  
  146. }
  147. // Triple 2st dart
  148. if ( x2.includes("T") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  149. t2 = 1;
  150.  
  151. soundGo( "http://autodarts.x10.mx/russ_bray/triple_beep.mp3", audio);
  152.  
  153. }
  154.  
  155. // Triple 3rd dart
  156. if ( x3.includes("T") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  157. t3 = 1;
  158.  
  159. soundGo( "http://autodarts.x10.mx/russ_bray/triple_beep.mp3", audio);
  160.  
  161. }
  162. }
  163. ///////////////////////////////////////////////// END TRIPLE CALLER ///////////////////////////
  164.  
  165. ///////////////////////////////////////////////// TRIPLE CALLER E-Dart Löwen///////////////////////////
  166. if(triplesound == 2) {
  167. // Triple 20 1st dart
  168. if ( x1.includes("T20") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  169. t1 = 1;
  170. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple20_old.wav", audio);
  171. }
  172. // Triple 19 1st dart
  173. if ( x1.includes("T19") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  174. t1 = 1;
  175. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple19_old.wav", audio);
  176. }
  177. // Triple 18 1st dart
  178. if ( x1.includes("T18") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  179. t1 = 1;
  180. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple18_old.wav", audio);
  181. }
  182. // Triple 17 1st dart
  183. if ( x1.includes("T17") && t1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  184. t1 = 1;
  185. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple17_old.wav", audio);
  186. }
  187.  
  188. /// 2. Dart
  189. // Triple 20 1st dart
  190. if ( x2.includes("T20") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  191. t2 = 1;
  192. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple20_old.wav", audio);
  193. }
  194. // Triple 19 1st dart
  195. if ( x2.includes("T19") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  196. t2 = 1;
  197. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple19_old.wav", audio);
  198. }
  199. // Triple 18 1st dart
  200. if ( x2.includes("T18") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  201. t2 = 1;
  202. soundGo(server+caller+"/SoundHwTriple18_old.wav", audio);
  203. }
  204. // Triple 17 1st dart
  205. if ( x2.includes("T17") && t2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  206. t2 = 1;
  207. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple17_old.wav", audio);
  208. }
  209.  
  210.  
  211. /// 3. Dart
  212. // Triple 20 1st dart
  213. if ( x3.includes("T20") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  214. t3 = 1;
  215. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple20_old.wav", audio);
  216. }
  217. // Triple 19 1st dart
  218. if ( x3.includes("T19") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  219. t3 = 1;
  220. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple19_old.wav", audio);
  221. }
  222. // Triple 18 1st dart
  223. if ( x3.includes("T18") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  224. t3 = 1;
  225. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple18_old.wav", audio);
  226. }
  227. // Triple 17 1st dart
  228. if ( x3.includes("T17") && t3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0){
  229. t3 = 1;
  230. soundGo("http://autodarts.x10.mx/russ_bray/SoundHwTriple17_old.wav", audio);
  231. }
  232.  
  233.  
  234. }
  235.  
  236.  
  237. ///////////////////////////////////////////////// Miss CALLER ///////////////////////////
  238. if(boosound == 1){
  239.  
  240. // miss 1st dart
  241. if ( x1.includes("M") && m1 === 0 && $(".css-1tq00ko:eq(1)").closest('div').attr('class') == 'css-rzdgh7' && called == 0)
  242. { m1 = 1;
  243. soundGo("http://autodarts.x10.mx/russ_bray/miss_1st_dart.mp3", audio);
  244. }
  245. // miss 2st dart
  246. if ( x2.includes("M") && m2 === 0 && $(".css-1tq00ko:eq(2)").closest('div').attr('class') == 'css-rzdgh7' && called == 0)
  247. { m2 = 1;
  248. soundGo("http://autodarts.x10.mx/russ_bray/miss_2nd_dart.mp3", audio);
  249. }
  250.  
  251. // miss 3rd dart
  252. if ( x3.includes("M") && m3 === 0 && $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0)
  253. { m3 = 1;
  254. soundGo("http://autodarts.x10.mx/russ_bray/miss_3rd_dart.mp3", audio);
  255. }
  256. }
  257.  
  258.  
  259. // Caller reset
  260. if( (x1 == '' || $(".css-1tq00ko:eq(3)").closest('div').attr('class') != 'css-rzdgh7') && called == 1) {
  261. called = 0; busted = 0;
  262. }
  263.  
  264.  
  265. // Caller if 3rd Dart has score and called = 0
  266. if( $(".css-1tq00ko:eq(3)").closest('div').attr('class') == 'css-rzdgh7' && called == 0 && caller != 'x') {
  267.  
  268. //add 00 to score
  269. // if(x0 < 10) {x0 = "00"+x0;}
  270. // else if(x0 <100) { x0 = "0"+x0 ;}
  271. soundGo(server+caller+x0+dotmp3, audio);
  272.  
  273. console.log('Caller Ausgabe!');
  274. called = 1;
  275. t1 = 0; t2 = 0; t3 = 0;
  276. m1 = 0; m2 = 0; m3 = 0;
  277. }
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285. // Caller-Select einfügen wenn noch nicht existiert
  286. if($("#caller").length == 0) {
  287.  
  288. $(".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>');
  289. $(document).on('change', '#caller', function(){
  290. caller = $("#caller").find(":selected").val();
  291.  
  292. if(caller == 'russ_bray') {
  293. server = 'http://autodarts.x10.mx/';
  294. caller = 'russ_bray/';
  295. dotmp3 = '.mp3';
  296. $("#caller option[value='russ_bray']").prop('selected', true);
  297. }
  298.  
  299. if(caller == 'google_eng') {
  300. dotmp3 = '';
  301. language = 'en';
  302. server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
  303. caller = '/';
  304. $("#caller option[value='google_eng']").prop('selected', true);
  305.  
  306. }
  307.  
  308. if(caller == 'google_de') {
  309. dotmp3 = '';
  310. language = 'de';
  311. server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
  312. caller = '/';
  313. $("#caller option[value='google_de']").prop('selected', true);
  314. }
  315.  
  316. if(caller == 'google_fr') {
  317. dotmp3 = '';
  318. language = 'fr';
  319. server = 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl='+language+'&q=';
  320. caller = '/';
  321. $("#caller option[value='google_fr']").prop('selected', true);
  322. }
  323. })
  324.  
  325. // Triple-Select
  326. $(".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>');
  327. $(document).on('change', '#triplesound', function(){
  328. triplesound = $("#triplesound").find(":selected").val();
  329.  
  330.  
  331. })
  332.  
  333.  
  334. // Boo-Select
  335. $(".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>');
  336. $(document).on('change', '#boosound', function(){
  337. boosound = $("#boosound").find(":selected").val();
  338.  
  339.  
  340. })
  341.  
  342. }
  343.  
  344.  
  345. },200);
  346.  
  347.  
  348.  
  349.  
  350. });
  351.  
  352.  
  353. })();