Skribbl.io Helper

Retrieves the wordlist and outputs possible words in chat. Based off of n0thing's Skribbl.io Helper.

  1. // ==UserScript==
  2. // @name Skribbl.io Helper
  3. // @version 0.02
  4. // @description Retrieves the wordlist and outputs possible words in chat. Based off of n0thing's Skribbl.io Helper.
  5. // @author n0thing, jakecrowley
  6. // @match https://skribbl.io/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/en/users/500647-jakecrowley
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var wordlist; //declare global scope wordlist var
  15. $.get("https://raw.githubusercontent.com/jakecrowley/Skribblio-Wordlist-Scraper/master/SkribblioWordlistScraper/bin/Debug/wordlist.json", function(data, status){
  16. wordlist = data.substring(1, data.length - 1);
  17. console.log("[Skribbl.io Helper] Loaded " + (wordlist.match(/,/g) || []).length + " words");
  18. });
  19.  
  20. var wordhint;
  21. var wordRGX;
  22. var i;
  23.  
  24. //create message element
  25. var messageelement = document.createElement('p');
  26. messageelement.setAttribute('style', 'display: none');
  27. messageelement.setAttribute('id','botChat');
  28. var c = document.createElement('span');
  29. c.setAttribute('id','hint');
  30. messageelement.appendChild(c);
  31. document.getElementById('containerSidebar').insertBefore(messageelement, document.getElementById('containerSidebar').childNodes[0]); //insert bot chat
  32.  
  33. document.getElementById('containerFreespace').setAttribute('style','display: none');
  34.  
  35. var css = document.createElement('style');
  36. 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);}';
  37. document.body.appendChild(css);
  38.  
  39. document.getElementById('inputChat').setAttribute('placeholder', 'Press ALT to toggle matching words'); // input wordhint into chat
  40.  
  41. var hidden = true;
  42.  
  43. document.getElementsByTagName("body")[0].onkeyup = function() {
  44. if (event.key === "Alt" ){
  45. hidden = !hidden;
  46. }
  47. };
  48.  
  49. var currentWord = "";
  50.  
  51. setInterval(function() {
  52. if(document.getElementById('currentWord') != null && !hidden){
  53. if(currentWord != document.getElementById('currentWord').textContent){
  54. chatbot();
  55. currentWord = document.getElementById('currentWord').textContent;
  56. }
  57. } else {
  58. document.getElementById('botChat').setAttribute('style','display: none');
  59. currentWord = "";
  60. }
  61. }, 500);
  62.  
  63. function chatbot(){
  64. var wordRGX = document.getElementById('currentWord').textContent;
  65.  
  66. while (wordRGX.charAt(0) === '_' || wordRGX.charAt(wordRGX.length-1) === '_'){
  67. if (wordRGX.charAt(0) === '_'){
  68. wordRGX = wordRGX.replace('_','[^ ]');
  69. } else if(wordRGX.charAt(wordRGX.length-1) === '_'){
  70. wordRGX = wordRGX.replace(/_$/,'[^ ]');
  71. }
  72. }
  73. wordRGX = wordRGX.replace(/_/g,'[^ ]');
  74. wordRGX = '"'.concat(wordRGX,'"');
  75. wordRGX = new RegExp(wordRGX, 'g');
  76.  
  77. var wordhint = wordlist.match(wordRGX).filter(function(f){return !f.includes(',');}).sort().toString().replace(/"/g,'').replace(/,/g,', '); // clean up result for bot chat
  78.  
  79. //if (document.getElementById('botChat').attributes[0].value.search('display: none') != -1){//if hidden
  80. document.getElementById('hint').innerHTML = wordhint.substring(0, 700);
  81. document.getElementById('botChat').setAttribute('style','display:');
  82.  
  83. document.getElementById('boxMessages').scrollTop = document.getElementById('boxMessages').scrollHeight; //scrollto bottom of chat
  84. }
  85. })();