-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclTrollCrusher.js
1996 lines (1638 loc) · 72 KB
/
clTrollCrusher.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name ClistTrollCrusher
// @namespace HWH
// @description This is a tool which will let you filter Craigslist Forum posts.
// @include http://forums.craigslist.org/*
// @include https://forums.craigslist.org/*
// @version 2014.04.23
// @grant none
// ==/UserScript==
//
// This script was modified by Handlewaeshere, from original script still available at:
// http://fbastage.zxq.net/cl_highlight.js
// as of 2014.04.23
//----------
// CraiglistTrollCrusher [modified version of CraigslistFriendHighlighter (modified version of CraigslistTrollBlocker)]
//
// Please consider this script released under GPL
//
// Offers a configurable list for highlighting <s>blocking</s> handles on forums in CL. All
// posts for listed handles will be <s>over-written with an innocuous message</s> highlighted.
// This is great for <s>blocking</s> spotting those <s>annoyances from idiots</s> awesome peeps.
//
// Handlewaeshere update allows for completely removing posts from CRUSHed trolls
//
// --------------------------------------------------------------------
//
//
// ----------------------------------------------------------------------------------
// set up a few 'constants'
//DIVIFY is needed for the highlight function and possible future functions, but it slows the script down. disable for performance
if(typeof DIVIFY == "undefined") var DIVIFY = true;
//version info
if(typeof $ver$ == "undefined") $ver$ = "2014.02.04";
if(typeof $DEBUG == "undefined") var $DEBUG = false;
if(typeof malecolor == "undefined") var malecolor = "RoyalBlue"; // "DodgerBlue" is also nice
if(typeof femalecolor == "undefined") var femalecolor = "HotPink";
if(typeof defaultcolor == "undefined") var defaultcolor = "darkgreen";
if(typeof highlightcolor == "undefined") var highlightcolor = "palegreen";
if(typeof male == "undefined") var male = new Array("m", "male", "man", "b", "boy", "guy");
if(typeof female == "undefined") var female = new Array("f", "female", "woman", "w", "g", "girl");
/*
* Troll List
*
* We are going to make the list of trolls configurable by the user.
*/
// Start with "do" functions: called directly by user actions
function doOpenTrollList() {
// alert("doOpenTrollList");
openTrollList();
return false;
}
function doTrollListOKButton() {
// alert("doTrollListOKButton");
if (storeTrollList()) {
closeTrollList();
blockTrolls();
//window.location.reload();
}
return false;
}
function doTrollListCancelButton() {
// alert("doTrollListCancelButton");
closeTrollList();
return false;
}
function doTrollListApplyButton() {
// alert("doTrollListApplyButton");
if (storeTrollList()) {
loadTrollList();
blockTrolls();
//window.location.reload();
}
return false;
}
// Now the "heavy-lifting", helper functions
function closeTrollList() {
// alert("closeTrollList");
loadTrollList();
hideTrollList();
}
function openTrollList() {
// alert("openTrollList");
loadTrollList();
showTrollList();
}
function showTrollList() {
var trollListDiv = document.getElementById("trollListDiv");
var trollListHiddenDiv = document.getElementById("trollListHiddenDiv");
//trollListDiv.style.position = "fixed";
//trollListDiv.style.scrollTop = trollListHiddenDiv.style.scrollTop;
trollListDiv.style.visibility = "visible";
trollListHiddenDiv.style.visibility = "hidden";
}
function hideTrollList() {
var trollListDiv = document.getElementById("trollListDiv");
var trollListHiddenDiv = document.getElementById("trollListHiddenDiv");
//trollListHiddenDiv.style.position = "fixed";
//trollListHiddenDiv.style.scrollTop = trollListDiv.style.scrollTop;
trollListHiddenDiv.style.visibility = "visible";
trollListDiv.style.visibility = "hidden";
}
function loadTrollList() {
/*
alert("loadTrollList()");
alert("Current trollBlockerEnabled: "+document.getElementById("trollBlockerEnabled").checked+
"\nCurrent trollList: \n"+document.getElementById("trollListContent").value);
//*/
// first try getting values from localStorage. if that fails, check cookies.
var trollList = "";
var trollBlockerEnabled;
var trollBlockerFiltered;
if (localStorage) {
trollList = localStorage.getItem("clTB.trollListContent");
trollBlockerEnabled = localStorage.getItem("clTB.trollBlockerEnabled");
trollBlockerFiltered = localStorage.getItem("clTB.trollBlockerFiltered");
}
if (trollList == "") {
trollList = getCookie("clTB.trollListContent");
trollBlockerEnabled = getCookie("clTB.trollBlockerEnabled");
trollBlockerFiltered = getCookie("clTB.trollBlockerFiltered");
}
//if (! trollBlockerEnabled) { trollBlockerEnabled = "false"; }
if (trollList == "") {
trollList = "Example1\r\nExample2|crush\r\nExample3|#F5F5DC\r\nExample4|block\r\nExample5|ignore";
}
if (! trollBlockerFiltered) { trollBlockerFiltered = "false"; }
/*alert("Stored trollBlockerEnabled: "+trollBlockerEnabled+
"\nStored trollList: \n"+trollList);
//*/
document.getElementById("trollListContent").value = trollList;
document.getElementById("trollBlockerEnabled").checked = (trollBlockerEnabled != "false");
document.getElementById("trollBlockerFiltered").checked = (trollBlockerFiltered != "false");
/*
alert("Set trollBlockerEnabled: "+document.getElementById("trollBlockerEnabled").checked+
"\nSet trollList: \n"+document.getElementById("trollListContent").value);
//*/
}
function storeTrollList() {
//if it's in filtered mode, check for changes, but use the original list
var filter = document.getElementById("trollListFilterText").value.toLowerCase();
var trollList = document.getElementById("trollListContent").value.split("\n");
var oldList = "";
if (localStorage)
var oldList = localStorage.getItem("clTB.trollListContent");
else
var oldList = getCookie("clTB.trollListContent");
if (oldList) oldList = oldList.split("\n");
if (filter != "") {
//var filterList = new Array(); // list of stuffs that match the filter
//delete any entries in filterList (we'll re-add them with the "oldList" values
for (t in oldList) {
if (oldList[t].toLowerCase().indexOf(filter) > -1) {
oldList[t] = "";
}
//alert("oldList length is: " + oldList.length);
}
for (t in trollList) {
var newtroll = trollList[t].trim();
if (newtroll && oldList.indexOf(newtroll) < 0) {
oldList.push(newtroll);
}
}
//remove empty values from array, and move to trollList (new version)
var trollList = new Array();
for (k = 0; k < oldList.length; k++) { if(oldList[k]) trollList.push(oldList[k]) }
//trollList = oldList;
document.getElementById("trollListFilterText").value = "";
}
var trollArray = trollList.sort(function(x,y){
var a = String(x).toUpperCase();
var b = String(y).toUpperCase();
if (a > b)
return 1
if (a < b)
return -1
return 0;
});
trollList = trollArray.join("\n");
trollList = trollList.replace(/ +/g, ''); //replace space character
var trollBlockerEnabled = document.getElementById("trollBlockerEnabled").checked;
var trollBlockerFiltered= document.getElementById("trollBlockerFiltered").checked;
/*
alert("Set trollBlockerEnabled: "+trollBlockerEnabled+
"\nSet trollList: \n"+trollList);
//*/
// store into localStorage. store as cookie if localStorage fails
var result;
if (localStorage) {
localStorage.setItem("clTB.trollBlockerEnabled", trollBlockerEnabled);
localStorage.setItem("clTB.trollBlockerFiltered", trollBlockerFiltered);
result = localStorage.setItem("clTB.trollListContent", trollList);
result = true;
//localStorage.getItem("clTB.trollBlockerEnabled") + "\n" + localStorage.getItem("clTB.trollBlockerFiltered") + "\n" + localStorage.getItem("clTB.trollListContent"))
} else {
setCookie("clTB.trollBlockerEnabled", trollBlockerEnabled);
setCookie("clTB.trollBlockerFiltered", trollBlockerFiltered);
result = setCookie("clTB.trollListContent", trollList);
}
/*
alert("Stored trollBlockerEnabled: "+getCookie("clTB.trollBlockerEnabled")+
"\nStored trollList: \n"+getCookie("clTB.trollListContent"));
//*/
// if (result) alert("Stored Troll List:\n"+trollList);
return result;
}
// show only a filtered version of the trolllist, based on text in trollListFilterText
function filterTrollList() {
filter = this.value;
if (filter.indexOf(' ') > -1) {
filter = this.value.replace(/ +/g, '').trim();
this.value = filter;
return;
}
filter = filter.toLowerCase().trim();
if (localStorage)
trollList = localStorage.getItem("clTB.trollListContent");
if (trollList == "")
trollList = getCookie("clTB.trollListContent");
//if (! trollBlockerEnabled) { trollBlockerEnabled = "false"; }
if (trollList == "") {
trollList = "Example1\r\nExample2|red\r\nExample3|#F5F5DC\r\nExample4|block\r\nExample5|ignore";
document.getElementById("trollListContent").value = trollList;
return;
}
//create new list
trollarray = trollList.split("\n")
newtrollarray = new Array();
for (t in trollarray) {
if (trollarray[t].toLowerCase().indexOf(filter) > -1)
newtrollarray.push(trollarray[t]);
}
trollList = newtrollarray.join("\r\n");
document.getElementById("trollListContent").value = trollList;
}
//block space character
function nospaces() {
}
/*
* Cookies
*
* We are going to save the list of trolls in a cookie.
* Here are some helper functions.
*/
function setCookie(c_name,c_value)
{
if (!testPersistentCookie()) {
alert ("Persistent cookies are currently disabled. "+
"You must enable persistent cookies to use "+
"Craig's List TrollCrusher");
return false;
}
writePersistentCookie (c_name, c_value, "years", 1);
return true;
}
function getCookie(c_name)
{
if (getCookieValue(c_name))
return getCookieValue(c_name);
return "";
}
function blockTrolls() {
var starttime = new Date().getTime(); //used for debug only
if (!document.getElementById("trollBlockerEnabled").checked) return;
//var trolls = document.getElementById("trollListContent").value.split("\n");
if (localStorage)
var trolls = localStorage.getItem("clTB.trollListContent").split("\n");
if (trolls == "")
var trolls = getCookie("clTB.trollListContent").split("\n");
// put friends/trolls into associative array
var fcolor;
var troll;
var trolltuple;
var trollhash = new Array();
for (j=0; j<trolls.length; j++) {
fcolor = defaultcolor; //default color for handles
troll = trolls[j].trim().toLowerCase();
trolltuple = troll.split('|');
troll = trolltuple[0].trim();
//if (post.search("class=\"hnd own") > -1) { fcolor = "red"; }
if (trolltuple.length > 1) {
fcolor = trolltuple[1].trim();
if (male.indexOf(fcolor) > -1) fcolor = malecolor;
else if (female.indexOf(fcolor) > -1) fcolor = femalecolor;
}
if (troll.length > 0) {
trollhash[troll] = fcolor;
}
}
//var blockedPosts = new Array();
var replaceRegex = new RegExp("<a .*>");
var replacementString = "<a style='color:darkgrey; text-decoration: line-through;' oonclick='return false;'>Post and Handle <b>IGNORE</b>d < Troll Blocker > </a>";
//var replaceRegex2 = new RegExp("<a .*<");
//var replacementString2 = "<a style='color:darkgrey; text-decoration: line-through;' oonclick='return false;'>Post <b>BLOCK</b>ed</a> <";
var replaceRegex2 = new RegExp("<a href=");
var replacementString2 = "<a style='color:darkgrey; text-decoration: line-through;' href=";
var replaceRegex3 = new RegExp('target="R"><b>.*</b></a> <');
var replacementString3 = 'target="R">Post <b>BLOCK</b>ed</a> <';
var reHandle = new RegExp("< .*>([A-Za-z0-9?!$^:()_-]+)<.* >");
var handle;
var postList = document.getElementById("div_threads");
if (! postList) { postList = document.body; d('could not find div_threads'); }
var origHTML = postList.innerHTML;
//var posts = postList.getElementsByTagName('div'); //
var posts = origHTML.split("\n");
var newPosts = new Array();
var lastPostThisLevelCrushed = new Array();
var levelThisPost = 0;
lastPostThisLevelCrushed[0] = 0;
// POST LOOP STARTS HERE
for (i=0; i<posts.length; i++) {
post = posts[i]; // .innerHTML;
if (post.length < 15 && document.getElementById("trollBlockerFiltered").checked) { continue; }
// some posts have extra <span> in them when there's a capital I...
// note: the code below won't catch all, because if multiple I's are used
// they will be in the same span definition. (i.e <span>II</span)
// and there may be more than one <span>I</span> in a handle.
// (i.e <span>I</span>_am_<span>I</span>). just not worth the
// computational time to compile a regular expression and execute it
// since these cases are rare
post = post.replace(/<span class="S">I<\/span>/g, 'i');
post = post.replace(/<span class="S">I<\/span>/g, 'i');
post = post.replace(/<span class="S">II<\/span>/g, 'ii');
post = post.replace(/<span class="S">III<\/span>/g, 'iii');
post = post.replace(/<span class="S">IIII<\/span>/g, 'iiii');
post = post.replace(/<span class="S">IIIII<\/span>/g, 'iiiii');
//post = post.replace(/rn/g, 'RN'); //some people like to use rn to imp someone with an M in the name
post = post.replace('color="#009900"><b>', 'color="#00FFFF"><b style="background-color:black; font-size: 150%">');
post = post.replace('<em>', '<em style="background-color:black; font-size: 150%">');
// catch some 'clever' invisible titles
post = post.replace('<b>' + String.fromCharCode(9), '<b style="color:brown;text-decoration: blink;">#');
post = post.replace('<b>' + String.fromCharCode(11), '<b style="color:brown;text-decoration: blink;">#');
post = post.replace('<b>' + String.fromCharCode(12), '<b style="color:brown;text-decoration: blink;">#');
post = post.replace('<b></b>', '<b style="color:brown;text-decoration: blink;">#</b>');
if(post.indexOf(String.fromCharCode(8201)) < 0) post = post.replace('</b>', ' </b>'); //thin space
// note if CR or LF are used, we need to concat the next line
if (post.indexOf("<b>") + 3 == post.length) {
//posts[i+1] = post + "<span style='color:brown;text-decoration: blink;'>#</span>" + posts[i+1];
// posts[i+1].innerHTML = post + posts[i+1].innerHTML;
posts[i+1] = post + posts[i+1];
post = "";
}
// handle is innerHTML between < and > skip this line if no handle found
if (post.search(reHandle) < 0) { posts[i] = post; continue; }
handle = post.match(reHandle)[1].toLowerCase();
//Gets heirarchy level of post
var cnt = 0;
var offset = 0;
var length = post.indexOf("<a");
var searchstring = ": . .";
var posttofindlevel = post;
searchstring += '';
posttofindlevel += '';
offset--;
while ((offset = posttofindlevel.indexOf(searchstring, offset + 1)) != -1) {
if (length > 0 && (offset + searchstring.length) > length) {
cnt=0;
}
cnt++;
}
levelThisPost = cnt;
/// End Gets Heirarchy
if (lastPostThisLevelCrushed[levelThisPost - 1] == 1) {
post = post.replace( ": . .", "c. .");
}
lastPostThisLevelCrushed[levelThisPost] = 0;
if (trollhash[handle] != undefined ) {
fcolor = trollhash[handle];
if (post.search("class=\"hnd own") > -1) { fcolor = "red"; }
if (fcolor=="ignore" && post.search(replacementString) < 0) {
//blockPost = true;
post = post.replace( replaceRegex, replacementString );
post = post.replace( "class=\"hnd hnd", "class=\"hnd hnd\" style=\"ccolor:darkgrey; background: bblack; text-decoration: line-through; font-size:small;");
post = post.replace( "class=\"hnd anon", "class=\"hnd anon\" style=\"ccolor:darkgrey; background: bdarkgrey; text-decoration: line-through; font-size:small;");
}
else if (fcolor=="block" && post.search(replacementString2) < 0) {
//blockPost = true;
post = post.replace( replaceRegex2, replacementString2 );
post = post.replace( replaceRegex3, replacementString3 );
post = post.replace( "class=\"hnd hnd", "class=\"hnd hnd\" style=\"color:darkgrey; background: bblack; text-decoration: line-through; font-size:small;");
post = post.replace( "class=\"hnd anon", "class=\"hnd anon\" style=\"color:darkgrey; background: bdarkgrey;text-decoration: line-through; font-size:small;");
}
else if (fcolor=="crush") {
//blockPost = true;
post = "";
lastPostThisLevelCrushed[levelThisPost] = 1;
}
else if(post.search(replacementString) < 0 && post.search(replacementString2) < 0) {
post = post.replace( "class=\"hnd", "class=\"hnd anon" );
post = post.replace( "class=\"hnd hnd", "class=\"hnd hnd\" style=\"color: " + fcolor + "; background: Moccasin; font-weight: bold");
post = post.replace( "class=\"hnd anon", "class=\"hnd anon\" style=\"color: " + fcolor + "; background: powderblue; font-weight: bold");
post = post.replace( "class=\"hnd own", "class=\"hnd own\" style=\"color: " + fcolor + "; background: Moccasin; font-weight: bold");
}
} // end for(j) loop
if (document.getElementById("trollBlockerFiltered").checked) {
if (trollhash[handle] != undefined) {
var replaceRegex3 = new RegExp("<b>.*<\/b><\/a>");
//post = post.replace( replaceRegex3 , "<b>♥____</b></a>" );
//replaceRegex3 = new RegExp("(: \. \. )+");
//post = post.replace( / : \. \. /g , ".");
posts[i] = post; //posts[i].innerHTML = post;
}
}
else { posts[i] = post; } //posts[i].innerHTML = post; }
} // end for(i) loop
//d(posts[lasti].innerHTML);
postList.innerHTML = posts.join('\n');
endtime = new Date().getTime();
difftime = endtime - starttime;
//d("time to block trolls: " + Math.round(difftime / 10) / 100 + " seconds");
}
function initTrollBlocker () {
var docHTML = document.body.innerHTML;
var strHTML = docHTML.substring(0, 300);
//alert(strHTML);
//if (docHTML == "Unable to process request, please try again. ") { return 0; }
//badness ="<html><body><pre>Unable to process request, please try again. </pre>";
var foundUTPR = strHTML.search("Unable to process request") ;
if (strHTML == "") foundUTPR = 1;
if (foundUTPR > -1) { return 0; alert("|" + strHTML + "|"); }
//if (docHTML.length() < 100) { alert("docHTML.length() == " + docHTML.length()); return; }
// move document's tables inside divs
tables = new Array();
// make a copy of tables array
for (i = 0; i < document.getElementsByTagName('table').length ; i++) {
tables[i] = document.getElementsByTagName('table')[i];
}
// cache initial window height
var upperdivheight = 0;
starttime = new Date().getTime();
// set up search reg exp to convert search link into a search form
var replacestr = '<form method="GET" action="?" target="_blank" name="frm"><input size="15" name="SQ" value=""><input type="hidden" name="act" value="RSR"><input type="hidden" name="searchAID" value=""><input type="hidden" name="forumID" value="_forumid_"><input type="submit" value="search"></form>';
var searchstr = '<a href="\\?fsid=(\\d+)" target="_top">search[^<]+</a>';
searchstr = new RegExp(searchstr);
var found = false;
for (i = 0; i < tables.length ; i++) {
t = tables[i];
div = document.createElement('div');
if (t.className == "fbod threads") {
div.id = "div_threads";
found = true;
var new_t = t.cloneNode(true);
new_t.id = "fbodthreads";
// remove the first break line
var inner = new_t.getElementsByTagName('td')[0].innerHTML;
new_t.getElementsByTagName('td')[0].innerHTML = inner.replace("<br>", "");
if (DIVIFY) {
var inner = new_t.getElementsByTagName('td')[0].innerHTML;
inner = inner.split("<br>");
for (j in inner) {
// locate post ID
var regex = new RegExp("act=Q&ID=(\\d+)");
if (inner[j].match(regex)) {
id = RegExp.$1;
inner[j] = "<div id='"+id+"'>" + inner[j] + "</div>";
}
}
new_t.getElementsByTagName('td')[0].innerHTML = inner.join("\n\n");
}
div.appendChild(new_t);
div.style.overflow = "auto";
div.style.border = "solid #bbb 1px";
div.style.width = "97%";
div.style.position = "absolute";
div.style.top = 10 + upperdivheight + "px";
//div.style.height = "90%";
var height = Math.round(100*(window.innerHeight - 15 - upperdivheight) / window.innerHeight);
div.style.height = height + "%";
document.body.appendChild(div);
//t.parentNode.removeChild(t);
} else if (!found) {
var targetstr = t.innerHTML;
if (targetstr.match(searchstr)) {
replacestr = replacestr.replace("_forumid_", RegExp.$1)
t.innerHTML = targetstr.replace(searchstr, replacestr);
}
upperdivheight += t.offsetHeight;
div.appendChild(t.cloneNode(true));
document.body.appendChild(div);
}
t.parentNode.removeChild(t);
}
//else { alert(docHTML.substring(0, 300)); }
endtime = new Date().getTime();
difftime = endtime - starttime;
//d("Time to set up tables " + Math.round(difftime / 10) / 100 + " seconds");
var stylesheet = document.createElement("style");
stylesheet.innerHTML = ".hnd:hover{ text-transform:lowercase_; text-decoration: underline;}";
if (document.styleSheets[1].href.indexOf('day') > -1) {
stylesheet.innerHTML += ".topLinks{background-color: #f4f4f4 ; border : solid #bbb 1px; }";
} else {
stylesheet.innerHTML += ".topLinks{background-color: #000 ; border : solid #bbb 1px; }";
}
stylesheet.innerHTML += ".topLinks{ opacity: 0.85; -moz-opacity: 0.85; }";
stylesheet.innerHTML += ".topLinks:hover { opacity: 1; -moz-opacity: 1; } ";
stylesheet.innerHTML += "a[target=R]:hover b { background-color: #BFEFF8; color: black; } ";
stylesheet.innerHTML += "a[target=R]:visited:hover b { background-color: #FFCFFF; color: black; } ";
document.body.insertBefore(stylesheet,document.body.firstChild);
var trollListTableRow;
var trollListTableData;
// This layer is displayed when the Troll List is "closed"
var trollListHiddenDiv ;
trollListHiddenDiv = document.createElement("div");
trollListHiddenDiv.id="trollListHiddenDiv";
trollListHiddenDiv.name="trollListHiddenDiv";
trollListHiddenDiv.align="right";
//trollListHiddenDiv.style.width = document.body.clientWidth + "px"; // "100%";
//trollListHiddenDiv.style.zIndex = -1;
trollListHiddenDiv.style.position = "fixed";
trollListTable = document.createElement("table");
trollListTable.bgColor= "#e0e0e0";
trollListTable.border=1;
trollListTable.width=25;
trollListTable.addEventListener("click", doOpenTrollList, false);
trollListHiddenDiv.appendChild(trollListTable);
trollListHiddenDiv.style.visibility = "visible";
//trollListHiddenDiv.style.top = 100; // document.body.scrollTop + 5;
//trollListHiddenDiv.style.left = document.body.clientWidth - 100 + "px"; //600px // document.body.scrollLeft + document.body.clientWidth - 25 - trollListTable.width;
trollListHiddenDiv.style.zIndex = 10;
trollListHiddenDiv.style.right = 40 + "px";
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
//trollListTableData.bgColor = "Silver";
trollListTableData.align="center";
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
var trollListOpenLink = document.createElement("a");
trollListOpenLink.id="trollListOpenLink";
trollListOpenLink.name="trollListOpenLink";
//trollListOpenLink.href="#";
trollListOpenLink.onclick="return false;";
trollListTableData.appendChild(trollListOpenLink);
//trollListOpenLink.appendChild(trollListOpenLink = document.createElement("em"));
trollListOpenLink.appendChild(trollListOpenLink = document.createElement("font"));
trollListOpenLink.size=1;
trollListOpenLink.color="red";
//trollListOpenLink.style.fontWeight="bold";
trollListOpenLink.appendChild(document.createTextNode("User List"));
// This layer is displayed when the Troll List is "open"
var trollListBR;
var trollListDiv = document.createElement("div");
trollListDiv.id="trollListDiv";
trollListDiv.name="trollListDiv";
trollListDiv.style.visibility = "hidden";
trollListDiv.style.position = "fixed"; //
trollListDiv.align="right";
trollListDiv.style.zIndex = 10;
//trollListDiv.style.width = document.body.clientWidth+"px";
//trollListDiv.style.top = 5; // document.body.scrollTop + 5;
//trollListDiv.style.left = document.body.clientWidth - 240 + "px"; // document.body.scrollLeft + document.body.clientWidth - 25 - trollListTable.width;
trollListDiv.style.right = 40 + "px";
// an X button to close the div
var xbtn = document.createElement('button');
xbtn.type = "button";
xbtn.id = "xbutton";
xbtn.innerHTML = "x";
xbtn.style.position = "relative";
xbtn.style.top = "30px";
xbtn.style.right = "5px";
//xbtn.style.height = "10px";
//xbtn.style.width = "10px";
//xbtn.style.float = "right";
xbtn.addEventListener("click", doTrollListCancelButton, false);
trollListDiv.appendChild(xbtn);
var trollListTableRow;
var trollListTableData;
trollListTable = document.createElement("table");
trollListTable.border=1;
trollListTable.width=180;
trollListTable.bgColor="Silver"; // "#f4f4f4";
trollListDiv.appendChild(trollListTable);
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
trollListTable = document.createElement("table");
trollListTable.border=0;
trollListTable.width=180;
trollListTableData.appendChild(trollListTable);
var trollListHeader = document.createElement("em");
trollListHeader.id="trollListHeader";
trollListHeader.name="trollListHeader";
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
trollListTableData.appendChild(trollListHeader);
var trollListHeaderContent = document.createTextNode("TrollCrusher User List");
trollListHeader.appendChild(trollListHeaderContent);
var trollListInfo = document.createElement("font");
trollListInfo.size=1;
var trollListInfoContent = document.createTextNode("handle|crush handle|block handle|ignore handle|'color' handle|female or handle|male");
trollListBR = document.createElement("br");
trollListTableData.appendChild(trollListBR);
trollListTableData.appendChild(trollListInfo);
trollListInfo.appendChild(trollListInfoContent);
// add a row with a label that says "filter:" and a textbox for a filter
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
var trollListFilterFont = document.createElement("font");
trollListFilterFont.size=1;
var trollListFilterLabel = document.createTextNode("filter:");
trollListHeader.appendChild(trollListHeaderContent);
var trollListFilterText = document.createElement("input");
trollListFilterText.type = "text";
trollListFilterText.id = "trollListFilterText";
trollListFilterText.addEventListener("keydown", nospaces, false);
trollListFilterText.addEventListener("keyup", filterTrollList, false);
trollListTableData.appendChild(trollListFilterFont);
trollListFilterFont.appendChild(trollListFilterLabel);
trollListTableData.appendChild(trollListFilterText);
// next row contains list of trollios
var trollListContent = document.createElement("textarea");
trollListContent.id="trollListContent";
trollListContent.name="trollListContent";
//trollListContents.style.margin-left="0px";
trollListContent.cols=24;
trollListContent.rows=10;
trollListContent.className = "color";
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
trollListTableData.appendChild(trollListContent);
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTableData.align="right";
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
var trollListButtonRow = document.createElement("span");
trollListTableData.appendChild(trollListButtonRow);
var trollListOKButton = document.createElement("input");
trollListOKButton.id="trollListOKButton";
trollListOKButton.name="trollListOKButton";
trollListOKButton.value="OK";
trollListOKButton.type="button";
trollListOKButton.style.fontSize="7pt";
trollListOKButton.addEventListener("click", doTrollListOKButton, false);
trollListButtonRow.appendChild(trollListOKButton);
var trollListCancelButton = document.createElement("input");
trollListCancelButton.id="trollListCancelButton";
trollListCancelButton.name="trollListCancelButton";
trollListCancelButton.value="Cancel";
trollListCancelButton.type="button";
trollListCancelButton.style.fontSize="7pt";
trollListCancelButton.addEventListener("click", doTrollListCancelButton, false);
trollListButtonRow.appendChild(document.createTextNode(" "));
trollListButtonRow.appendChild(trollListCancelButton);
var trollBlockerEnabled = document.createElement("input");
trollBlockerEnabled.id="trollBlockerEnabled";
trollBlockerEnabled.name="trollBlockerEnabled";
trollBlockerEnabled.type="checkbox";
var trollBlockerEnabledLabel = document.createElement("label");
trollBlockerEnabledLabel.appendChild(trollBlockerEnabled);
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
trollListTableData.appendChild(trollBlockerEnabledLabel);
trollBlockerEnabledLabel.appendChild(trollBlockerEnabledLabel = document.createElement("font"));
trollBlockerEnabledLabel.size=2;
trollBlockerEnabledLabel.appendChild(document.createTextNode(" enable Troll Crusher"));
var trollBlockerFilter = document.createElement("input");
trollBlockerFilter.id="trollBlockerFiltered";
trollBlockerFilter.name="trollBlockerFiltered";
trollBlockerFilter.type="checkbox";
trollBlockerFilter.disabled = "1";
trollBlockerFilter.style.visibility = "hidden";
var trollBlockerFilterLabel = document.createElement("label");
trollBlockerFilterLabel.appendChild(trollBlockerFilter);
trollListTableRow = document.createElement("tr");
trollListTableData = document.createElement("td");
trollListTable.appendChild(trollListTableRow);
trollListTableRow.appendChild(trollListTableData);
trollListTableData.appendChild(trollBlockerFilterLabel);
trollBlockerFilterLabel.appendChild(trollBlockerFilterLabel = document.createElement("font"));
trollBlockerFilterLabel.size=2;
trollBlockerFilterLabel.appendChild(document.createTextNode("version: " + $ver$)); //(" Filter out all except"));
/*
var trollListApplyButton = document.createElement("input");
trollListApplyButton.id="trollListApplyButton";
trollListApplyButton.name="trollListApplyButton";
trollListApplyButton.value="Apply";
trollListApplyButton.type="button";
trollListApplyButton.style.fontSize="7pt";
trollListApplyButton.addEventListener("click", doTrollListApplyButton, false);
trollListButtonRow.appendChild(document.createTextNode(" "));
trollListButtonRow.appendChild(trollListApplyButton);
*/
dt = document.getElementById('div_threads');
if (false) {
//alert(trollListDiv + " " + trollListHiddenDiv);
dt.insertBefore(trollListDiv , dt.firstChild);
dt.insertBefore(trollListHiddenDiv, dt.firstChild);
//alert("dt: " + dt + "\nadded " + topLinksHiddenDiv);
} else {
//alert(":( new_t not found");
document.body.insertBefore(trollListDiv, document.body.firstChild);
document.body.insertBefore(trollListHiddenDiv, document.body.firstChild);
}
var postsList = document.getElementById("topLinksTable"); //document.getElementsByTagName("table")[2];
if (postsList) {
postsList.parentNode.insertBefore(trollListDiv,postsList);
} else {
document.body.insertBefore(trollListDiv,document.body.firstChild);
}
closeTrollList();
}
function d(str) {
if ($DEBUG) alert(str);
}
// Enhance String a bit.
String.prototype.trimLeft = function() {
return this.replace(/^\s+/,'');
}
String.prototype.trimRight = function() {
return this.replace(/\s+$/,'');
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,'');
}
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// COOKIE HELPERS /////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*==============================================================================
Routines written by John Gardner - 2003 - 2005
See www.braemoor.co.uk/software for information about more freeware
available.
================================================================================
*/
/*==============================================================================
Routine to get the current value of a cookie
Parameters:
cookieName Cookie name
Return value:
false Failed - no such cookie
value Value of the retrieved cookie
e.g. if (!getCookieValue("pans") then {
cookieValue = getCoookieValue ("pans2);
}
*/
function getCookieValue (cookieName) {
var exp = new RegExp (escape(cookieName) + "=([^;]+)");
if (exp.test (document.cookie + ";")) {
exp.exec (document.cookie + ";");
return unescape(RegExp.$1);
}
else return false;
}
/*==============================================================================
Routine to see of persistent cookies are allowed:
Parameters:
None
Return value:
true Session cookies are enabled
false Session cookies are not enabled
e.g. if (testPersistentCookie()) then
alert ("Persistent coookies are enabled");
else
alert ("Persistent coookies are not enabled");
*/
function testPersistentCookie () {
writePersistentCookie ("testPersistentCookie", "Enabled", "minutes", 1);
if (getCookieValue ("testPersistentCookie")=="Enabled")
return true
else
return false;
}
/*==============================================================================
Routine to write a persistent cookie
Parameters:
CookieName Cookie name
CookieValue Cookie Value
periodType "years","months","days","hours", "minutes"
offset Number of units specified in periodType
Return value:
true Persistent cookie written successfullly
false Failed - persistent cookies are not enabled
e.g. writePersistentCookie ("Session", id, "years", 1);
*/
function writePersistentCookie (CookieName, CookieValue, periodType, offset) {
var expireDate = new Date ();
offset = offset / 1;
var myPeriodType = periodType;
switch (myPeriodType.toLowerCase()) {
case "years":
var year = expireDate.getYear();
// Note some browsers give only the years since 1900, and some since 0.
if (year < 1000) year = year + 1900;
expireDate.setYear(year + offset);
break;
case "months":
expireDate.setMonth(expireDate.getMonth() + offset);
break;
case "days":
expireDate.setDate(expireDate.getDate() + offset);
break;
case "hours":
expireDate.setHours(expireDate.getHours() + offset);
break;
case "minutes":
expireDate.setMinutes(expireDate.getMinutes() + offset);