This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
skp_script.js
229 lines (187 loc) · 11.5 KB
/
skp_script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// ==UserScript==
// @name skribbl.io+
// @name:de skribbl.io+
// @version 0.1
// @description Skribbl.io improvements
// @description:de Skribbl.io Verbesserungen
// @namespace https://github.com/Sv443
// @author Sv443
// @license MIT
// @copyright 2018, Sv443 (https://github.com/Sv443)
// @match http*://www.skribbl.io/*
// @match http*://skribbl.io/*
// @grant GM_addStyle
// @grant GM_listValues
// @grant GM_deleteValue
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_openInTab
// @grant GM_notification
// @grant GM_setClipboard
// @icon https://raw.githubusercontent.com/Sv443/code/master/resources/favicons/skribbl.io%2B%20icon.png
// @run-at document-start
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @connect self
// @connect *
// @updateURL https://raw.githubusercontent.com/Sv443/skribbl.io-plus/master/skp_script.js
// @downloadURL https://raw.githubusercontent.com/Sv443/skribbl.io-plus/master/skp_script.js
// @supportURL https://github.com/Sv443/skribbl.io-plus/issues
// ==/UserScript==
/*\ \ \ Settings Settings Settings Settings / / /*/
/* \ \ \ Settings Settings Settings Settings Settings / / / */
/* / / / Settings Settings Settings Settings \ \ \ */
/*/ / / Settings Settings Settings Settings Settings \ \ \*/
var dbg = false; //enable javascript console debug (default: false, can be true or false)
var lang = "en"; //change the localization ("en" for english, "de" for german)
var del_content = "X"; //content of the delete box (default: "X") (you can also use HTML if you want to)
var feature_delete_messages = true; //feature that prepends a delete box on every message that deletes it on click (it's a bit useless but eh, why not?) (default: true, can be true or false)
var feature_download_png = true; //adds a download as png button underneath the votekick button (default: true, can be true or false)
var feature_watermark = true; //adds a watermark, if you don't like it, you can disable it here (default: true, can be true or false)
var feature_hard_mode = true; //adds a button that can switch to hard mode on click (the hint at the top will disappear) (default: true, can be true or false)
/* Changelog Changelog Changelog Changelog Changelog Changelog Changelog Changelog */
// what's new in this version:
// - prepends delete box on every message that deletes it on click
// - appends download drawing button underneath the votekick button
// - appends hard mode button underneath the download drawing button that disables the word hint at the top and the chat
var curversion = GM_info.script.version;
var URLhost = window.location.host;
var URLpath = window.location.pathname;
var curURL = URLhost + "" + URLpath;
var qStr = window.location.search.substring(1);
var running = false;
var lang_delete_message, lang_deleted, lang_download_as_png, lang_download_as_png_desc, lang_opens_in_new_tab, lang_activate_hard_mode, lang_activate_hard_mode_desc, lang_word_hint_disabled, lang_chat_disabled;
var lang_confirm_hard_mode;
switch(lang){
case "en":
lang_delete_message = "Delete this message";
lang_deleted = "deleted";
lang_download_as_png = "Download Drawing";
lang_download_as_png_desc = "Click to download the drawing as a PNG file";
lang_opens_in_new_tab = "(Opens in a new tab)";
lang_activate_hard_mode = "Hard Mode";
lang_activate_hard_mode_desc = "Removes the word hint at the top and disables the chat";
lang_word_hint_disabled = "(hints disabled)";
lang_chat_disabled = "(chat disabled)";
lang_confirm_hard_mode = "Do you really want to activate the hard mode?\nThis will disable the word hint and the chat and can only be undone by reloading the page.";
break;
case "de":
lang_delete_message = "Lösche diese Nachricht";
lang_deleted = "gelöscht";
lang_download_as_png = "Zeichnung herunterladen";
lang_download_as_png_desc = "Klicke, um die Zeichnung als PNG herunterzuladen";
lang_opens_in_new_tab = "(Öffnet sich in einem neuen Tab)";
lang_activate_hard_mode = "Schwerer Modus";
lang_activate_hard_mode_desc = "Entfernt den Worthinweis oben und deaktiviert den Chat";
lang_word_hint_disabled = "(Hinweise deaktiviert)";
lang_chat_disabled = "(Chat deaktiviert)";
lang_confirm_hard_mode = "Willst du wirklich den schweren Modus aktivieren?\nDies wird alle Worthinweise und den Chat deaktivieren und kann nur rückgängig gemacht werden, wenn du die Seite neu lädst.";
break;
default:
lang_delete_message = "Delete this message";
lang_deleted = "deleted";
lang_download_as_png = "Download Drawing";
lang_download_as_png_desc = "Click to download the drawing as a PNG file";
lang_opens_in_new_tab = "(Opens in a new tab)";
lang_activate_hard_mode = "Hard Mode";
lang_activate_hard_mode_desc = "Removes the word hint at the top and disables the chat";
lang_word_hint_disabled = "(hints disabled)";
lang_chat_disabled = "(chat disabled)";
lang_confirm_hard_mode = "Do you really want to activate the hard mode?\nThis will disable the word hint and the chat and can only be undone by reloading the page.";
break;
}
(function() {
'use strict';
console.log("skribbl.io+ v" + curversion + " - by Sv443 / Sven Fehler - GitHub: https://github.com/sv443/skribbl.io-plus - debug enabled: " + dbg);
setInterval(function(){
if(isrunning() === true){
GM_setValue("running", "true");
}
else{
GM_setValue("running", "false");
}
}, 500);
function isrunning() {
if(document.getElementById("timer").innerHTML < 80){return true;}
else{return false;}
}
setInterval(function(){
/*Delete Messages Delete Messages Delete Messages Delete Messages Delete Messages*/
/*Delete Messages Delete Messages Delete Messages Delete Messages Delete Messages*/
if(feature_delete_messages){
var prependvalue = '<span id="skp_del_message" class="skp_msg_del" style="text-decoration:none;font-weight:bold;color:red;cursor:pointer;" title="' + lang_delete_message + '">' + del_content + '</span> ';
running = parseBool(GM_getValue("running"));
if(running){
var cn = document.getElementById("boxMessages").childNodes;
for(var i = 0; i < cn.length; i++){
var cnih = cn[i].innerHTML;
if(!cnih.includes(prependvalue) && !cnih.includes("(" + lang_deleted + ")")){
cn[i].innerHTML=prependvalue + cnih;
cn[i].querySelector("#skp_del_message").addEventListener("click", function(){this.parentNode.innerHTML="(" + lang_deleted + ")";});
}
if(cnih === undefined){break;}
}
}
}
/*UI UI UI UI UI UI UI*/
/*UI UI UI UI UI UI UI*/
if(feature_download_png){
document.addEventListener("DOMContentLoaded", function() {
if(!document.body.innerHTML.includes("skp_dl_elem")){
var canvas = document.getElementById("canvasGame");
var skp_dl_elem = document.createElement("a");
skp_dl_elem.id="skp_dl_elem";
skp_dl_elem.style="text-decoration:none;";
skp_dl_elem.innerHTML='<div style="height:1vh;"></div><button class="btn btn-warning btn-block" title="' + lang_download_as_png_desc + '">' + lang_download_as_png + '</button>';
skp_dl_elem.addEventListener("click", function(){
skp_dl_elem.href = canvas.toDataURL();
skp_dl_elem.download = "skribbl_io.png";
if(dbg){console.log("downloading drawing");}
});
document.getElementsByClassName("tooltip-wrapper")[0].appendChild(skp_dl_elem);
}
});
}
if(feature_hard_mode){
document.addEventListener("DOMContentLoaded", function() {
if(!document.body.innerHTML.includes("skp_hard_mode_elem")){
var skp_hard_mode_elem = document.createElement("a");
skp_hard_mode_elem.id="skp_hard_mode_elem";
skp_hard_mode_elem.style="text-decoration:none;";
skp_hard_mode_elem.innerHTML='<div style="height:1vh;"></div><button class="btn btn-warning btn-block" title="' + lang_activate_hard_mode_desc + '">' + lang_activate_hard_mode + '</button>';
skp_hard_mode_elem.addEventListener("click", function(){
if(confirm(lang_confirm_hard_mode)){
setInterval(function(){
document.getElementById("currentWord").innerHTML=lang_word_hint_disabled;
document.getElementById("boxMessages").innerHTML=lang_chat_disabled;
var msgs = document.getElementsByClassName("message");
for(var i = 0; i < msgs.length; i++){
msgs[i].innerHTML="";
}
},25);
if(dbg){console.log("activating hard mode");}
}
else {
if(dbg){console.log("cancelled hard mode confirmation");}
}
});
document.getElementsByClassName("tooltip-wrapper")[0].appendChild(skp_hard_mode_elem);
}
});
}
if(feature_watermark){
running = parseBool(GM_getValue("running"));
if(!document.body.innerHTML.includes("skp_watermark")){
var watermark = document.createElement("div");
watermark.innerHTML="skribbl.io+ v" + curversion + ' (<a href="https://github.com/Sv443/skribbl.io-plus" target="blank_" title="' + lang_opens_in_new_tab + '">GitHub</a>)';
watermark.id="skp_watermark";
watermark.align="center";
watermark.style="color:white;font-size:1.25em;position:fixed;top:1vh;right:1vh;";
document.getElementsByClassName("header")[0].appendChild(watermark);
GM_addStyle(`html, body {margin: 0; height: 100%; overflow: hidden}`);
}
}
}, 100);
function parseBool(val) {
return val === true || val === "true";
}
})();