Advertisement
arthurcluet

Untitled

May 13th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // ==UserScript==
  2. // @name gomoku
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://gomoku.yjyao.com/
  8. // @icon https://www.google.com/s2/favicons?domain=yjyao.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (async function() {
  13. 'use strict';
  14.  
  15. // Your code here...
  16. let last = -1;
  17. let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  18. let p= true;
  19. let inp = false;
  20.  
  21. window.calc = (mv) => {
  22. let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  23. return alphabet.indexOf(mv[0]) + (parseInt(mv.slice(1))-1) * 15;
  24. }
  25.  
  26. window.p = (mv) => {
  27. document.querySelectorAll("div[currentPlayer] > .gomoku-10 > div")[window.calc(mv)].click()
  28. }
  29.  
  30.  
  31.  
  32. //document.querySelectorAll("div[currentPlayer] > .gomoku-10 > div")[N].click()
  33.  
  34. //window.p(window.prompt())
  35.  
  36.  
  37. while(true){
  38. let m = Array.from(document.querySelectorAll("div[currentPlayer] > .gomoku-10 > div")).indexOf(document.querySelector('[isLastMove][spot="0"]'))
  39. if(m != last){
  40. last = m;
  41. let col = last % 15;
  42. let row = parseInt(last / 15);
  43. if(alphabet[col]){
  44. console.log(alphabet[col] + "" + (row+1));
  45. p = true;
  46. inp = true;
  47.  
  48. }
  49.  
  50. }
  51. if(document.querySelector('[isprimary="true"]') && p){
  52. console.log("Nouvelle partie");
  53. p = false;
  54. } else if(inp) {
  55. window.p(window.prompt())
  56. inp = false;
  57.  
  58. }
  59.  
  60.  
  61. await new Promise(r => setTimeout(r, 100));
  62. }
  63.  
  64.  
  65. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement