Skribbl.io AutoGuesser

Goes into Skribbl.io's console to guess possible outputs, and puts them in chat.

  1. // ==UserScript==
  2. // @name Skribbl.io AutoGuesser
  3. // @version 1.0
  4. // @description Goes into Skribbl.io's console to guess possible outputs, and puts them in chat.
  5. // @author `
  6. // @match https://skribbl.io/*
  7. // @grant none
  8. // @namespace https://gf.qytechs.cn/
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. if (localStorage.getItem('wordlist') !== null) {
  15. window.alert('Hi! I\'m `, I am the developer of Skribbl.io AutoGuesser, and I just wanted to tell you that this script took a LONG time to make. Please rate honestly, it would mean alot!')
  16. }
  17.  
  18. //create wordlist name, check if wordlist localstorage exists upon joining game
  19. var wordlist; //declare global scope wordlist var
  20. document.querySelector('#formLogin > button').onclick = function(){
  21. wordlist = 'wordlist' + document.querySelector('#loginLanguage').value;
  22. if (localStorage.getItem(wordlist) === null) {
  23. localStorage.setItem(wordlist,'""');
  24. }
  25. };
  26.  
  27. var wordhint;
  28. var wordRGX;
  29. var i;
  30.  
  31. //create message element
  32. var messageelement = document.createElement('p');
  33. messageelement.setAttribute('style', 'display: none');
  34. messageelement.setAttribute('id','botChat');
  35. var c = document.createElement('span');
  36. c.setAttribute('id','hint');
  37. messageelement.appendChild(c);
  38. document.getElementById('containerSidebar').insertBefore(messageelement, document.getElementById('containerSidebar').childNodes[0]); //insert bot chat
  39.  
  40. document.getElementById('containerFreespace').setAttribute('style','display: none');
  41.  
  42. var css = document.createElement('style');
  43. css.innerHTML = '#botChat{ border-radius: 2px; background: rgb(238, 238, 238); width:inherit-5px; overflow-wrap: break-word; position:absolute;right:0;top:3px;left:3px; color: rgb(206, 79, 10);}';
  44. document.body.appendChild(css);
  45.  
  46. document.getElementById('inputChat').setAttribute('placeholder', 'Press F2 to open matching words'); // when F2 is pressed it opens wordhint which you then click it for it to chat
  47.  
  48. document.getElementsByTagName("body")[0].onkeyup = function() {
  49. if (event.key === "F2" ){
  50. chatbot();
  51. }};
  52.  
  53. //mutationObserver > trigger wordCapture
  54. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  55. var element = document.querySelector('#overlay > div > div.text');
  56. var observer = new MutationObserver(function(mutations) {
  57. mutations.forEach(function(mutation) {
  58. if (mutation.type == 'childList') {
  59. if (document.querySelector('#overlay > div > div.text').textContent.startsWith("Choose a word")){wordchoiceCapture();}; //trigger wordCatupre() when turn ends
  60. if (document.querySelector('#overlay > div > div.text').textContent.startsWith("The word was")){wordCapture();};
  61. }
  62. });
  63. });
  64. observer.observe(element, {
  65. childList: true
  66. });
  67.  
  68. //capture word from skribbl.io after round
  69. function wordCapture() {
  70. var word = document.querySelector('#overlay > div > div.text').textContent.slice(14);
  71. if (localStorage.getItem(wordlist).search( '"' + word + '"') === -1){
  72. if (word.endsWith('word!') === false){
  73. localStorage.setItem(wordlist,localStorage.getItem(wordlist) + ',"' + word + '"'); //updates localstorage
  74. }
  75. }
  76. }
  77. function wordchoiceCapture() { //Is called twice by mutation observer
  78. var wordchoicelist = [];
  79. for (i = 0; i < document.getElementsByClassName("word").length; i++){
  80. wordchoicelist.push(document.getElementsByClassName("word")[i].textContent); //collects words from word options when it's the player's turn to draw.
  81. }; // somehow creates undefined,"word1","word2","word3"
  82. console.log(wordchoicelist)
  83. for (i = 0; i < wordchoicelist.length; i++){
  84. if (localStorage.getItem(wordlist).search( '"' + wordchoicelist[i] + '"') === -1){
  85. localStorage.setItem(wordlist,localStorage.getItem(wordlist) + ',"' + wordchoicelist[i] + '"');
  86. }
  87. }
  88. }
  89.  
  90. function chatbot(){
  91. var wordRGX = document.getElementById('currentWord').textContent;
  92.  
  93. while (wordRGX.charAt(0) === '_' || wordRGX.charAt(wordRGX.length-1) === '_'){
  94. if (wordRGX.charAt(0) === '_'){
  95. wordRGX = wordRGX.replace('_','[^ ]');
  96. } else if(wordRGX.charAt(wordRGX.length-1) === '_'){
  97. wordRGX = wordRGX.replace(/_$/,'[^ ]');
  98. }
  99. }
  100. wordRGX = wordRGX.replace(/_/g,'[^ ]');
  101. wordRGX = '"'.concat(wordRGX,'"');
  102. wordRGX = new RegExp(wordRGX, 'g');
  103.  
  104. var wordhint = localStorage.getItem(wordlist).match(wordRGX).filter(function(f){return !f.includes(',');}).sort().toString().replace(/"/g,'').replace(/,/g,', '); // clean up result for bot chat
  105.  
  106. if (document.getElementById('botChat').attributes[0].value.search('display: none') != -1){//if hidden
  107. document.getElementById('hint').innerHTML = wordhint;
  108. document.getElementById('botChat').setAttribute('style','display:');
  109. } else {document.getElementById('botChat').setAttribute('style','display: none');}
  110.  
  111. document.getElementById('boxMessages').scrollTop = document.getElementById('boxMessages').scrollHeight; //scrollto bottom of chat
  112. }
  113. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址