Skribbl.io Helper

Learns the wordlist each round and outputs possible words in chat.

当前为 2018-11-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Skribbl.io Helper
// @version      0.11
// @description  Learns the wordlist each round and outputs possible words in chat.
// @author       n0thing
// @match        https://skribbl.io/*
// @grant        none
// @namespace https://greasyfork.org/users/90770
// ==/UserScript==

(function() {
    'use strict';

//check if wordlist localstorage exists
if (localStorage.getItem('wordlist') === null) {
localStorage.setItem('wordlist','""');
}

var wordhint;
var wordRGX;

document.getElementById('inputChat').setAttribute('placeholder', 'Press ALT to open matching words');  // input wordhint into chat

document.getElementsByTagName("body")[0].onkeyup = function() {
            if (parseInt(event.keyCode) == 18 ){
							chatbot();
						}};

//mutationObserver > trigger wordCapture
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var element = document.querySelector('.revealReason');
var observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    if (mutation.type == 'attributes') {
      wordCapture();
    }
  });
});
observer.observe(element, {
  attributes: true
});

//capture word from skribbl.io after round
function wordCapture() {
 var word = document.querySelector('#overlay > div > div.text').textContent.slice(14);
 if (localStorage.wordlist.search(word) === -1){
 	if (word.endsWith('word!') === false){
localStorage.setItem('wordlist',localStorage.wordlist + ',"' + word + '"');  //updates localstorage
}
 }
}

function chatbot(){
  var wordRGX = document.getElementById('currentWord').textContent;

while (wordRGX.charAt(0) === '_' || wordRGX.charAt(wordRGX.length-1) === '_'){
if (wordRGX.charAt(0) === '_'){
      wordRGX = wordRGX.replace('_','\\w');
    } else if(wordRGX.charAt(wordRGX.length-1) === '_'){
      wordRGX = wordRGX.replace(/_$/,'\\w');
    }
  }
  wordRGX = wordRGX.replace(/_/g,'\\w');
  wordRGX = '"'.concat(wordRGX,'"');
  wordRGX = new RegExp(wordRGX, 'g');

	var wordhint = localStorage.wordlist.match(wordRGX).filter(function(f){return !f.includes(',');}).sort().toString().replace(/"/g,'').replace(/,/g,', '); // clean up result for bot chat

	//create message element
	var a = document.createElement('p');
	a.setAttribute('style', 'color: rgb(206, 79, 10);');
	var b = document.createElement('b');
	a.appendChild(b);
	var c = document.createElement('span');
	c.setAttribute('id','hint');
	a.appendChild(c);
	var d = document.createTextNode('bot: ');
	b.appendChild(d);
	var e =document.createTextNode(wordhint);
	c.appendChild(e);

	//insert bot chat
	document.getElementById('boxMessages').appendChild(a); //insert bot chat
	document.getElementById('boxMessages').scrollTop = document.getElementById('boxMessages').scrollHeight; //scrollto bottom of chat

}
})();