Solving maths is fun

Solves fun math

目前為 2018-06-25 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Solving maths is fun
  3. // @description Solves fun math
  4. // @author Ko
  5. // @version 1.1
  6. // @include *.koalabeast.com:*
  7. // @include *.jukejuice.com:*
  8. // @include *.newcompte.fr:*
  9. // @icon https://github.com/wilcooo/TagPro-SolvingMathsIsFun/raw/master/icon.png
  10. // @supportURL https://www.reddit.com/message/compose/?to=Wilcooo
  11. // @website https://redd.it/no-post-yet
  12. // @license MIT
  13. // @namespace https://greasyfork.org/users/152992
  14. // ==/UserScript==
  15.  
  16.  
  17. tagpro.ready(function() {
  18.  
  19. var names = [];
  20.  
  21. tagpro.socket.on('p', function(p) {
  22.  
  23. for (var pu of (p.u || p)) {
  24.  
  25. if (pu.name != names[pu.id]) {
  26. names[pu.id] = pu.name;
  27.  
  28. if (pu.name && isNaN(pu.name) && pu.name.match(/^[ \d×÷=/*+-]+$/)) {
  29. try {
  30. var answer = eval(pu.name.replace('×','*').replace('÷','/').replace('=',''));
  31. setTimeout(tagpro.socket.emit,
  32. 500 + Math.random()*1000,
  33. 'chat', {message:String(answer)});
  34. } catch(e){}
  35. }
  36. }
  37. }
  38. });
  39. });