Avoid Winning

Change another winner if one of selected names is the winner (if possible, in case all objects in the race are excluded)

  1. // ==UserScript==
  2. // @name Avoid Winning
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-02-07
  5. // @description Change another winner if one of selected names is the winner (if possible, in case all objects in the race are excluded)
  6. // @author kaizisntme
  7. // @license MIT
  8. // @match https://www.online-stopwatch.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=online-stopwatch.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // In line 31, add your excluded names (add "" for name in lowercase, just a number for no.) seperated by commas, example: ["me", 1, 2, "me2"]
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. Number.prototype.toLowerCase=function() { return parseInt(this); }
  19. Array.prototype.shuffle=function()
  20. {
  21. var i = this.length, j, temp;
  22. if ( i === 0 ) return this;
  23.  
  24. while ( --i )
  25. {
  26. //j = Math.floor( Math.getRandomArbitrary() * ( i + 1 ));
  27. j = Math.getRandomArbitrary(0,i);
  28. temp = this[i];
  29. this[i] = this[j];
  30. this[j] = temp;
  31. }
  32. const excludes = ["me"]; // CONFIG HERE!!!
  33. if(this[0] && this[0].instance) {
  34. let arr = [];
  35. this.forEach((a, i) => {
  36. arr[i] = {...a, name: a.name.toLowerCase()};
  37. });
  38. if(excludes.includes(arr[0].name)) {
  39. const winners = arr.filter(a => !excludes.includes(a.name))
  40. const new_winner = winners[0] || arr[0];
  41. const idx = arr.indexOf(new_winner);
  42. temp = this[0];
  43. this[0] = this[idx];
  44. this[idx] = temp;
  45. }
  46. }
  47. return this;
  48. }
  49. })();