Advertisement
arthurcluet

Untitled

May 13th, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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.  
  20. window.calc = (mv) => {
  21. let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  22. return alphabet.indexOf(mv[0]) + (parseInt(mv.slice(1))-1) * 15;
  23. }
  24.  
  25. window.p = (mv) => {
  26. document.querySelectorAll("div[currentPlayer] > .gomoku-10 > div")[window.calc(mv)].click()
  27. }
  28.  
  29.  
  30.  
  31. //document.querySelectorAll("div[currentPlayer] > .gomoku-10 > div")[N].click()
  32.  
  33. while(true){
  34. let m = Array.from(document.querySelectorAll("div[currentPlayer] > .gomoku-10 > div")).indexOf(document.querySelector('[isLastMove][spot="1"]'))
  35. if(m != last){
  36. last = m;
  37. let col = last % 15;
  38. let row = parseInt(last / 15);
  39. if(alphabet[col]){
  40. console.log(alphabet[col] + "" + (row+1));
  41. p = true;
  42.  
  43. }
  44.  
  45. }
  46. if(document.querySelector('[isprimary="true"]') && p){
  47. console.log("Nouvelle partie");
  48. p = false;
  49. }
  50.  
  51.  
  52. await new Promise(r => setTimeout(r, 100));
  53. }
  54. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement