Fxp Message scribble

Spam those douchebags

当前为 2020-10-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fxp Message scribble
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Spam those douchebags
  6. // @author MrTarnegol
  7. // @match https://www.fxp.co.il/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. 'use strict';
  12.  
  13. const MIN_SIZE = 3;
  14. const MAX_SIZE = 5;
  15.  
  16. window.MIN_SIZE = MIN_SIZE;
  17. window.MAX_SIZE = MAX_SIZE;
  18.  
  19. const getText = () => {
  20. const selector = '.cke_editor iframe'
  21. const element = $(selector)[0];
  22. if (element !== undefined) {
  23. const doc = element.contentWindow.document;
  24. return doc.getElementsByClassName("forum")[0].innerText;
  25. }
  26. return '';
  27. }
  28. window.getText = getText;
  29.  
  30. const setText = (text) => {
  31. const selector = '.cke_editor iframe'
  32. const element = $(selector)[0];
  33. if (element !== undefined) {
  34. var doc = element.contentWindow.document;
  35. doc.getElementsByClassName("forum")[0].innerText = text;
  36. return true;
  37. }
  38. return false;
  39. }
  40. window.setText = setText;
  41.  
  42. const randomSize = () => {
  43. const SIZES = MAX_SIZE - MIN_SIZE + 1;
  44. return Math.floor(Math.random() * SIZES) + MIN_SIZE;
  45. }
  46. window.randomSize = randomSize;
  47.  
  48. const letterWithSize = (letter, size = randomSize()) => {
  49. return letter != ' ' ? `[SIZE=${size}]${letter}[/SIZE]` : ' ';
  50. }
  51. window.letterWithSize = letterWithSize;
  52.  
  53. const scribbleText = (text) => {
  54. let isText = true;
  55. return text.split('').reduce((a, b) => {
  56. if (b == ']') { isText = true; return a + b; };
  57. if (b == '[') { isText = false; return a + b; };
  58. return isText ? a + letterWithSize(b) : a + b;
  59. }, '');
  60. }
  61. window.scribbleText = scribbleText;
  62.  
  63. const scribble = () => {
  64. console.log('MrTarnegol scribbling begin!');
  65.  
  66. const text = getText();
  67. const scribbled = scribbleText(text);
  68. setText(scribbled);
  69.  
  70. CKEDITOR.tools.callFunction(5, this);
  71. }
  72. window.scribble = scribble;
  73.  
  74. const scribbleButton = () => {
  75. const button = document.createElement('button');
  76. button.style.position = 'fixed';
  77. button.style.bottom = '0'; //'200px';
  78. button.style.left = 0;
  79. button.style.backgroundColor = '#73AD21';
  80. button.style.padding = '15px 40px';
  81. button.style.fontSize = '18px';
  82. button.innerText = 'ערבל טקסט';
  83. button.onclick = scribble;
  84. return button;
  85. }
  86.  
  87. const start = () => {
  88. if (window.top == window.self) {
  89. const btn = scribbleButton();
  90. document.body.appendChild(btn);
  91. }
  92. }
  93.  
  94. start();
  95.