-
Notifications
You must be signed in to change notification settings - Fork 0
/
betterufck.user.js
executable file
·319 lines (289 loc) · 14.5 KB
/
betterufck.user.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
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
// ==UserScript==
// @name BetterUfck
// @namespace http://freerobby.com
// @description Added features for ufck.org
// @include http://ufck.org/*
// ==/UserScript==
////////////////////////////////////////////////////////////////////
// Configuration - set values to true to enable; false to disable //
////////////////////////////////////////////////////////////////////
// Remove page title
var opt_pretendToBeGoogle = true;
// Append all thread titles with one-click "ignore thread" option
var opt_addIgnoreThreadLink = true;
var opt_addIgnoreThreadLinkText = '[i]';
// Append all thread titles with one-click "subscribe to thread" option
var opt_addSubscribeToThreadLink = true;
var opt_addSubscribeToThreadLinkText = '[s]';
// Add "Ignore this user" to user drop-down menu options
var opt_addIgnoreUserToUserMenu = true;
// Unbold thread titles
var opt_unboldThreadTitles = true;
// Gray out titles of read threads
var opt_grayReadThreads = false;
// Remove ignored user post message (you'll see nothing when an ignored user posts)
var opt_removeUserIsIgnoredMessage = true;
// Reduce size of super-big images so they look nice
var opt_reduceBigImages = true;
// Show full links instead of vB abbreviated ones
var opt_showFullLinks = true;
// Convert YouTube videso into links
var opt_spoilerEmbeddedObjects = true;
// Provide unignoring of threads
var opt_unignoreThreadOption = true;
////////////////////////////////////////////
// EDIT BELOW THIS LINE AT YOUR OWN RISK! //
////////////////////////////////////////////
//
if (opt_pretendToBeGoogle) {
document.title = 'Google';
var gfv = document.createElement('link');
gfv.setAttribute('type', 'image/x-icon');
gfv.setAttribute('rel', 'shortcut icon');
gfv.setAttribute('href', 'data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AAD///8A//3/AP39/wD6/f8A+P3/AP/8/wD9/P8A+vz/AP/7/wD/+v8A/vr/APz6/wD4+v8A+/n/APP5/wD/+P8A+vj/AO/4/wDm+P8A2fj/AP/3/wD/9v8A9vb/AP/1/wD69f8A9PT/AO30/wD/8/8A//L/APnx/wD28P8A///+APj//gD2//4A9P/+AOP//gD//f4A6f/9AP///AD2//wA8//8APf9/AD///sA/v/7AOD/+wD/+vsA9/X7APr/+gDv/voA///5AP/9+QD/+/kA+e35AP//+ADm//gA4f/4AP/9+AD0+/gA///3APv/9wDz//cA8f/3AO3/9wD/8fcA//32AP369gDr+vYA8f/1AOv/9QD/+/UA///0APP/9ADq//QA///zAP/18wD///IA/fzyAP//8QD///AA9//wAPjw8AD//+8A8//vAP//7gD9/+4A9v/uAP/u7gD//+0A9v/tAP7/6wD/+eoA///pAP//6AD2/+gA//nnAP/45wD38eYA/fblAP/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yyI3KSsp6mvpaqosaatq7axsQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=');
var head = document.getElementsByTagName('head')[0];
head.appendChild(gfv);
}
////////////////////////////////
// Unignore threads from list //
////////////////////////////////
if (isCurrentPage("showthread.php") && opt_unignoreThreadOption) {
// http://ufck.org/forums/cis_ignore_thread.php?do=u&t=218236
// Create an invisible i-frame to send html requests when threads are ignored.
var iframe = document.createElement("iframe");
iframe.width = 1;
iframe.id = "ignore_iframe";
iframe.height = 1;
iframe.style.visibility = "hidden";
document.body.appendChild(iframe);
var allLinks, thisLink;
allLinks = document.evaluate("//a", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
// Check that it's a thread link.
if ((thisLink.href.indexOf('http://ufck.org/forums/showthread.php?t=')==0) &&
(thisLink.parentNode.parentNode.parentNode.parentNode.parentNode.className.indexOf('postbody') == 0)) {
var postNode = document.createTextNode(' ');
var threadID = thisLink.href.match(/\d+/);
if (opt_addIgnoreThreadLink) {
var newElement = document.createElement("a");
newElement.setAttribute('href', '/forums/cis_ignore_thread.php?do=u&t=' + threadID);
newElement.setAttribute('title', 'Unignore this thread if it is ignored');
newElement.setAttribute('target', '_blank');
newElement.innerHTML = '[unignore]';
newElement.style.color='#999999';
newElement.style.textDecoration='none';
thisLink.parentNode.appendChild(newElement, thisLink);
thisLink.parentNode.appendChild(postNode, thisLink);
}
}
}
}
//////////////////////////////
// Spoiler Embedded Objects //
//////////////////////////////
if (isCurrentPage("showthread.php") && opt_spoilerEmbeddedObjects) {
var allDivs, thisDiv;
allDivs = document.evaluate("//div[@id]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allDivs.snapshotLength; i++) {
thisDiv = allDivs.snapshotItem(i);
// If this is a post, ...
if (thisDiv.id.indexOf('post_message_')==0) {
var spoilerStart = "<div style=\"margin:5px 20px 20px 20px\"><div class=\"smallfont\" style=\"margin-bottom:2px\"><b>Embedded Object Spoiler:</b> <input type=\"button\" value=\"Show\" style=\"width:45px;font-size:10px;margin:0px;padding:0px;\" onclick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }\"></div><div class=\"alt2\" style=\"margin: 0px; padding: 6px; border: 1px inset;\"><div style=\"display: none;\">";
var spoilerStop = "</div></div></div>";
// Get post content (HTML).
var postHTML = thisDiv.innerHTML;
// Remove embedded YouTube from post content.
var prefix = '<object';
var suffix = '</object>';
var lastFoundPos = 0;
var ytStartPos = postHTML.indexOf(prefix, lastFoundPos);
while (ytStartPos >= 0) {
var ytEndPos = postHTML.indexOf(suffix, lastFoundPos) + suffix.length;
var newHTML =
postHTML.substring(0, ytStartPos) +
spoilerStart +
postHTML.substring(ytStartPos, ytEndPos) +
spoilerStop +
postHTML.substring(ytEndPos, postHTML.length);
lastFoundPos =
postHTML.substring(0, ytStartPos).length +
spoilerStart.length +
postHTML.substring(ytStartPos, ytEndPos).length +
spoilerStop.length;
thisDiv.innerHTML = newHTML;
postHTML = thisDiv.innerHTML;
ytStartPos = postHTML.indexOf(prefix, lastFoundPos);
}
}
}
}
////////////////////////////////////////////////////
// Show full links instead of vB abbreviated ones //
////////////////////////////////////////////////////
if (isCurrentPage("showthread.php") && opt_showFullLinks) {
urlarray = document.evaluate('//a[@href]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
matchtext = new RegExp("/\.{3,3}[0-z]");
var rrdirect = 0; //if = 1, then try to remove prefixes like "http://anonym.to/?" etc.
for(var i = 0; i < urlarray.snapshotLength; i++) {
link = urlarray.snapshotItem(i);
if (link.firstChild) {
var d = link.firstChild.nodeValue;
var u = link.href;
match = matchtext.exec(d);
if (match) {
var linkparts = d.split("...");
var a = u.indexOf(linkparts[0].replace(/ +/g, ' ').replace(/^\s+/g, '').replace(/\s+$/g, ''));
var z = 0;
if (linkparts[1]){
z = u.indexOf(linkparts[1].replace(/ +/g, ' ').replace(/^\s+/g, '').replace(/\s+$/g, ''));
}
if (a != -1 && z != -1) {
if (rrdirect == 1) {
link.firstChild.nodeValue = u.slice(a);
}
else {
link.firstChild.nodeValue = u;
}
}
}
}
}
}
///////////////////////////////////////
// Reduce size of super large images //
///////////////////////////////////////
if (isCurrentPage("showthread.php") && opt_reduceBigImages) {
maxWidth = window.innerWidth * 0.7; // 70% of browser width
var aImg = document.getElementsByTagName('img');
for (j=0; j<aImg.length; j++) {
aImg[j].style.maxWidth = maxWidth + 'px';
if (! aImg[j].title)
aImg[j].title = 'Click image to restore full dimensions.';
aImg[j].addEventListener('click', function(event) {
if (event.currentTarget.style.maxWidth == 'none')
event.currentTarget.style.maxWidth = maxWidth + 'px';
else
event.currentTarget.style.maxWidth = 'none';
}, false);
}
}
////////////////////////////////////
// Remove user-is-ignored message //
////////////////////////////////////
if (isCurrentPage("showthread.php") && opt_removeUserIsIgnoredMessage) {
var filterkey = "profile.php?userlist=ignore&do=removelist&u=";
var allElements, thisElement;
allElements = document.getElementsByTagName('blockquote');
for (var i = 0; i < allElements.length; i++) {
thisElement = allElements[i];
if(thisElement.innerHTML.indexOf(filterkey) != -1) {
thisElement.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
}
}
}
////////////////////////////////////////////////
// Unbold thread titles and gray read threads //
////////////////////////////////////////////////
if ((isCurrentPage('forumdisplay.php') || isCurrentPage('search.php')) && (opt_unboldThreadTitles || opt_grayReadThreads)) {
var allLinks, thisLink;
allLinks = document.evaluate("//a", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
// Check that it's a thread link.
if ((thisLink.id.indexOf('thread_title_')==0)) {
thisLink.style.fontWeight="normal";
if (opt_grayReadThreads && thisLink.className.indexOf('threadtitle_unread')<0) {
thisLink.style.color="#666666";
}
}
}
}
/////////////////////////////////////////////////
// Check to see if we're at a particular page. //
/////////////////////////////////////////////////
function isCurrentPage(pageName)
{
var curLocation = location.href;
if (curLocation.indexOf(pageName) > 0)
return true;
else
return false;
}
////////////////////////////////////////////////////////////////////////////
// Add ignore thread and subscribe to thread features to main forum pages //
////////////////////////////////////////////////////////////////////////////
if ((isCurrentPage('forumdisplay.php') || isCurrentPage('search.php')) && (opt_addIgnoreThreadLink || opt_addSubscribeToThreadLink))
{
// Create an invisible i-frame to send html requests when threads are ignored.
var iframe = document.createElement("iframe");
iframe.width = 1;
iframe.id = "ignore_iframe";
iframe.height = 1;
iframe.style.visibility = "hidden";
document.body.appendChild(iframe);
var allLinks, thisLink;
allLinks = document.evaluate('//a[@href]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
if (thisLink.id.indexOf('thread_title_')>=0) {
var postNode = document.createTextNode(' ');
var threadID = thisLink.href.match(/\d+/);
if (opt_addIgnoreThreadLink) {
var newElement = document.createElement("a");
var undoElement = document.createElement("a");
var theJS =
'javascript:' +
'document.getElementById("ignore_iframe").src = "/forums/cis_ignore_thread.php?do=ignorethread&t=' +
threadID +
'";' +
//'javascript:this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode);';
'javascript:this.parentNode.parentNode.innerHTML=\'Thread Ignored. <a href="/forums/cis_ignore_thread.php?do=u&t='
+ threadID
+ '" target="_self">Undo</a>\'';
newElement.setAttribute('onclick', theJS);
newElement.setAttribute('title', 'Ignore this thread');
newElement.setAttribute('style', 'cursor:pointer;');
newElement.innerHTML = opt_addIgnoreThreadLinkText;
newElement.style.color='#999999';
newElement.style.textDecoration='none';
thisLink.parentNode.appendChild(newElement, thisLink);
thisLink.parentNode.appendChild(postNode, thisLink);
}
if (opt_addSubscribeToThreadLink) {
var subscribeElement = document.createElement("a");
subscribeElement.setAttribute("href", "/forums/subscription.php?do=addsubscription&t=" + threadID);
subscribeElement.setAttribute('title', 'Subscribe to this thread');
subscribeElement.innerHTML = opt_addSubscribeToThreadLinkText;
subscribeElement.style.color='#999999';
subscribeElement.style.textDecoration='none';
thisLink.parentNode.appendChild(subscribeElement, thisLink);
thisLink.parentNode.appendChild(postNode, thisLink);
}
}
}
}
/////////////////////////////////////////////////////////
// Add ignore user feature to user-click dropdown list //
/////////////////////////////////////////////////////////
if (isCurrentPage('showthread.php') && opt_addIgnoreUserToUserMenu)
{
var allMemberSections, thisMemberSection;
allMemberSections = document.evaluate('//a[@href]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allMemberSections.snapshotLength; i++) {
thisMemberSection = allMemberSections.snapshotItem(i);
// If we find a link to a member profile, ...
if (thisMemberSection.href.indexOf('profile.php?do=addlist') > 0) {
var userID = thisMemberSection.href.match(/\d+/);
// Construct the table row.
var node1 = document.createElement('li');
node1.setAttribute('class', 'left');
var node2 = document.createElement('a');
node2.setAttribute('href', 'profile.php?do=addlist&userlist=ignore&u=' + userID);
node2.innerHTML = '<img src="images/site_icons/add.png"></img> Add to ignore list';
node1.appendChild(node2);
// Add the list item.
thisMemberSection.parentNode.parentNode.appendChild(node1, thisMemberSection);
}
}
}