WSOP

GreaseMonkey / TamperMonkey script that show percentable status of actual bracelet level.

  1. // ==UserScript==
  2. // @id wsop-script@pida42
  3. // @name WSOP
  4. // @description GreaseMonkey / TamperMonkey script that show percentable status of actual bracelet level.
  5. // @namespace https://github.com/pida42/wsop-script
  6. // @version 1.0.0
  7. // @author You
  8. // @include http://*
  9. // @include https://*
  10. // @match http://*
  11. // @match https://*
  12. // @require https://code.jquery.com/jquery-2.1.4.min.js
  13. // @grant GM_addStyle
  14. // ==/UserScript==
  15.  
  16. (function (jQuery) {
  17.  
  18. if (false === document.location.host.match(/playwsop\.com/g)) return;
  19.  
  20. var intervals = {};
  21. var removeListener = function (selector) {
  22. if (intervals[selector]) {
  23. window.clearInterval(intervals[selector]);
  24. intervals[selector] = null;
  25. }
  26. };
  27. var found = 'waitUntilExists.found';
  28.  
  29. jQuery.fn.waitUntilExists = function (handler, shouldRunHandlerOnce, isChild) {
  30. var selector = this.selector;
  31. var $this = jQuery(selector);
  32. var $elements = $this.not(
  33. function () {
  34. return jQuery(this).data(found);
  35. }
  36. );
  37. if (handler === 'remove') {
  38. removeListener(selector);
  39. } else {
  40. $elements.each(handler).data(found, true);
  41. if (shouldRunHandlerOnce && $this.length) {
  42. removeListener(selector);
  43. } else if (!isChild) {
  44. intervals[selector] = window.setInterval(
  45. function () {
  46. $this.waitUntilExists(handler, shouldRunHandlerOnce, true);
  47. }, 500
  48. );
  49. }
  50. }
  51. return $this;
  52. };
  53.  
  54. jQuery('.bpMeterValueMask').waitUntilExists(
  55. function () {
  56. var _interval = null;
  57. clearInterval(_interval);
  58. _interval = window.setInterval(
  59. function () {
  60. if (jQuery('.bpMeterValueMask').length !== 0) {
  61. var meterValueMask = parseInt(jQuery('.bpMeterValueMask').css('width'));
  62. var meterContainer = parseInt(jQuery('.bpBarMeterContainer').css('width'));
  63. var bpValuePercent = ((meterValueMask / meterContainer) * 100);
  64. jQuery('.bpBarNextChip').text(parseFloat(bpValuePercent).toFixed(2) + '%').css({lineHeight: 5, fontSize: '20px'});
  65. }
  66. }, 5000
  67. );
  68. }
  69. );
  70.  
  71. })(jQuery);