Greasy Fork

Shined up real nice.

Greasy Fork is available in English.

monnsutogatya_tool

ADBlock Reborn and Refresh tool.

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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// ==UserScript==
// @name         monnsutogatya_tool
// @namespace    http://qqboxy.blogspot.com/
// @version      0.9.3
// @description  ADBlock Reborn and Refresh tool.
// @author	     QQBoxy
// @match        http://tw.monnsutogatya.com/*
// @grant        none
// ==/UserScript==

// Install https://greasyfork.org/zh-TW/scripts/12760-monnsutogatya-tool

(function() {
	function $(id) {
		switch(id.substr(0,1)) {
			case '#':
				return document.getElementById(id.substr(1));
			case '.':
				var elems = document.body.getElementsByTagName('*');
				var target = id.substr(1);
				var result=[];
				for(i=0;j=elems[i];i++) {
					if((j.className).indexOf(target)!=-1) result.push(j);
				}
				return result;
			default:
				return document.getElementsByTagName(id);
		}
	}
	
	var getCookie = function(name) {
		var n = name + "=";
		var nlen = n.length;
		var clen = document.cookie.length;
		var i = 0;
		while(i < clen) {
			var j = i + nlen;
			if(document.cookie.substring(i, j) == n) {
				var endstr = document.cookie.indexOf(";", j);
				if(endstr == -1)
					endstr = clen;
				return unescape(document.cookie.substring(j, endstr));
			}
			i = document.cookie.indexOf(" ", i) + 1;
			if(i == 0) break;
		}
		return null;
	};
	
	//----- Clear other
	
	var other = function() {
		var i = 0;
		var j = 0;
		var adclass = ["adsbygoogle", "adsense", "facebook-bnr"];
		for(i=0;i<adclass.length;i++) {
			var ads = $("."+adclass[i]);
			for(j=0;j<ads.length;j++) {
				ads[j].parentNode.removeChild(ads[j]);
			}
		}
	};
	
	//----- Control Bar-----
	var controlbar = function() {
		var tbox = document.getElementById("t-box");
		var ctrl = document.createElement("div");
		ctrl.setAttribute("style",
			"width: 950px;"+
			"white-space: nowrap;"+
			"text-align: center;"+
			"background-color: #848280;"+
			"border-bottom-style: solid;"+
			"border-bottom-width: 1px;"+
			"padding: 10px 0;"
		);
		
		ctrl.setAttribute("id", "ctrlboxy");
		
		var start = document.createElement("button");
		start.setAttribute("id", "startboxy");
		start.setAttribute("style",
			"font-size: 20px;"+
			"margin: 0 10px;"
		);
		
		var sec = document.createElement("input");
		sec.setAttribute("style",
			"width: 50px;"+
			"font-size: 20px;"+
			"margin-right: 10px;"
		);
		sec.setAttribute("id", "secboxy");
		
		var txt1 = document.createElement("span");
		txt1.setAttribute("style",
			"font-size: 20px;"+
			"margin-right: 10px;"+
			"color: #f0f0a9"
		);
		txt1.innerHTML = "秒, 同時抽到";
		
		var count = document.createElement("input");
		count.setAttribute("style",
			"width: 50px;"+
			"font-size: 20px;"+
			"margin-right: 10px;"
		);
		count.setAttribute("id", "countboxy");
		
		var txt2 = document.createElement("span");
		txt2.setAttribute("style",
			"font-size: 20px;"+
			"color: #f0f0a9"
		);
		txt2.innerHTML = "隻☆5時提醒";
		
		ctrl.appendChild(start);
		ctrl.appendChild(sec);
		ctrl.appendChild(txt1);
		ctrl.appendChild(count);
		ctrl.appendChild(txt2);
		
		tbox.parentNode.insertBefore(ctrl, tbox);
	};
	
	//----- Refresh Tool -----
	
	var refresh_tool = function() {
		var ms = null;
		var started = null;
		var refreshTimmer = null;
		var keyTimer = null;
		
		var set = function() {
			var c_started = getCookie("c_started");
			var c_ms = getCookie("c_ms");
			if(c_ms && ms==null) {
				ms = c_ms;
			} else if(!c_ms && ms==null) {
				ms = 60000;
			}
			document.cookie = "c_ms=" + escape(ms);
			document.getElementById('secboxy').value = ms/1000;

			if(c_started && started==null) {
				if(c_started=="true") {
					started = true;
				} else if(c_started=="false") {
					started = false;
				}
			} else if(!c_started && started==null) {
				started = false;
			}
			document.cookie = "c_started=" + escape(started);
			clearTimeout(refreshTimmer);
			if(started) {
				document.getElementById('startboxy').innerHTML = "自動重新整理(啟用中)";
				refreshTimmer = setTimeout(function(){
					location.reload();
				}, ms);
			} else {
				document.getElementById('startboxy').innerHTML = "自動重新整理(停止中)";
			}
		};
		
		var startboxy = document.getElementById("startboxy");
		startboxy.onclick = function() {
			if(started) {
				started = false;
			} else {
				started = true;
			}
			set();
		};
		
		var secboxy = document.getElementById("secboxy");
		secboxy.onkeyup = function() {
			if(keyTimer) clearTimeout(keyTimer);
			keyTimer = setTimeout(function() {
				ms = parseInt(document.getElementById('secboxy').value, 10) * 1000;
				if(ms>=5000) {
					set();
				} else {
					alert("不允許小於5秒");
				}
			}, 500);
		};
		
		set();
	};
	
	//----- Alert Tool -----
	
	var alert_tool = function() {
		var mp3 = "https://dl.dropboxusercontent.com/u/12316009/ms/StrikeShot.mp3";
		var i = 0;
		var j = 0;
		var c = 0;
		var cardtime = {};
		var tp = /☆5\s(\d+)\:(\d+)/;
		var cards = $("#c-box").getElementsByTagName("h1");
		for(i=0;i<cards.length;i++) {
			var m = cards[i].innerHTML.match(tp);
			if(m) {
				var n = parseInt(m[1], 10)*60+parseInt(m[2], 10);
				if(cardtime[n]) {
					cardtime[n]++;
				} else {
					cardtime[n] = 1;
				}
			} else {
				cards[i].parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
			}
		}
		//console.log(JSON.stringify(cardtime));
		
		var countboxy = document.getElementById("countboxy");
		countboxy.onkeyup = function() {
			c = parseInt(document.getElementById('countboxy').value, 10);
			document.cookie = "c_count=" + escape(c);
		};
		
		var c_count = getCookie("c_count");
		if(c_count) {
			c = parseInt(c_count, 10);
		} else {
			c = 3; //預設值
			document.cookie = "c_count=" + escape(c);
		}
		countboxy.value = c;
		
		var c_cardtime = getCookie("c_cardtime");
	   	
		if(c_cardtime != JSON.stringify(cardtime)) {
			var c_cardtime_obj = JSON.parse(c_cardtime);
			document.cookie = "c_cardtime=" + escape(JSON.stringify(cardtime));
			
			for(p in c_cardtime_obj) {
				for(q in cardtime) {
					if(q == p) {
						delete cardtime[p];
					}
				}
			}
			
			for(j in cardtime) {
				//console.log(parseInt((j/60), 10), ":", j%60);
				if(cardtime[j] >= c) {
					var audio = document.createElement('audio');
					audio.autoplay = "autoplay";
					var source = document.createElement('source');
					source.src = mp3;
					source.type = "audio/mpeg";
					audio.appendChild(source);
					document.getElementsByTagName("body")[0].appendChild(audio);
					break;
				}
			}
			
		}
	};
	
	// Remove AD
	var del = function() {
		var remove = function(obj) {
			obj.parentNode.removeChild(obj);
		};
		
		for(var i = 1; i < 100; i++) {
			clearTimeout(i);
		}
		$("#for-ad-blocker").style.display="none";
		$("#site-box").style.display="";
		$("#a-box").style.marginBottom = "-15px";
		$("#ypaAdWrapper-monst_2a").innerHTML="";
		$("#ypaAdWrapper-monst_2b").innerHTML="";
	};
	
	//主函式
	if(navigator.userAgent.match("Firefox")) {
		del();
		controlbar();
		refresh_tool();
		alert_tool();
		window.onload = function() {
			other();
		};
	} else {
		del();
		controlbar();
		other();
		refresh_tool();
		alert_tool();
	}
})();