Solving maths is fun

Solves fun math

目前为 2018-06-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Solving maths is fun
  3. // @description Solves fun math
  4. // @author Ko
  5. // @version 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.match(/^[ \d×÷=/*+-]+$/)) {
  29. try {
  30. var answer = eval(pu.name.replace('×','*').replace('÷','/').replace('=',''));
  31. tagpro.socket.emit('chat', {message:String(answer)});
  32. } catch(e){}
  33. }
  34. }
  35. }
  36. });
  37. });