-
Notifications
You must be signed in to change notification settings - Fork 0
/
PressPass.user.js
1329 lines (1171 loc) · 65.9 KB
/
PressPass.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
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 PressPass
// @version 2.1.2
// @grant GM.getValue
// @grant GM.setValue
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
// JPxG, 2021 September 9 - 2023 November 1
( function() {
var settingsDefault = {
"style": 1,
"multi": 0,
"spacing": 0,
"date": 1,
"accdate": 1,
"via": 1,
"week": 1,
"length": 1
};
// Default settings.
var variable;
var settings;
async function loadSettings(varDefault) {
variable = await GM.getValue("pressPassConfig", JSON.stringify(varDefault));
settings = JSON.parse(variable);
}
try {
loadSettings(settingsDefault);
} catch(e) {settings = settingsDefault;}
// The first thing we're going to do is try and retrieve the settings from local storage. If that doesn't work, we will use defaults.
// Make it a try block per documentation at http://greasemonkey.win-start.de/advanced/gm_getvalue.html
var settingsOpen = 0;
// Settings are not currently open, so set this to zero.
function settingsToggle() {
console.log("Toggling settings");
if (settingsOpen == 0){
settingsWindow();
}
if (settingsOpen == 1){
settingsClose();
}
settingsOpen = 1 - settingsOpen;
}
var setHTML = document.createElement ('div');
setHTML.innerHTML = ' \
<div id="settingsBox" style="background:#002b36; color:#859900;"> \
<p>\
<em><b>PressPass v2.1, by JPxG (<a href="https://github.com/jp-x-g/PressPass">https://github.com/jp-x-g/PressPass</a>)</b></em>\
<small><small><small><br /><em> Against all the ignorance and wickedness of the world burns fiercely the small torch of knowledge, freedom, and properly formatted citations.</em></small></small></small>\
<br />\
<span style="font: monospace;">Citation style:</span>\
<input type="radio" name="stylebox" id="stylebox1" value="st1">\
EN.WP\
<input type="radio" name="stylebox" id="stylebox2" value="st2">\
MLA9\
<input type="radio" name="stylebox" id="stylebox3" value="st3">\
APA7\
<input type="radio" name="stylebox" id="stylebox4" value="st4">\
Chicago\
<input type="radio" name="stylebox" id="stylebox5" value="st5">\
BiBTeX\
<br />\
<br />\
<b>Settings for Wikipedia citation templates</b>\
<br />\
<input type="checkbox" name="authbox" id="authbox1" value="au1">\
Parse author names from clipping tags\
<br />\
Date format:<br />\
<input type="radio" name="datefbox" id="datefbox1" value="df1">\
1969-12-31 (best: this is the international standard)<br />\
<input type="radio" name="datefbox" id="datefbox2" value="df2">\
31 December 1969<br />\
<input type="radio" name="datefbox" id="datefbox3" value="df3">\
31 Dec 1969<br />\
<input type="radio" name="datefbox" id="datefbox4" value="df4">\
Dec 31, 1969 (avoid if possible)<br />\
<input type="radio" name="datefbox" id="datefbox5" value="df5">\
December 31, 1969 (avoid if possible)<br />\
<br />\
Optional parameters:\
<br />\
<input type="checkbox" name="setbox1" value="sb1"> <span style="font-family: monospace">access-date</span>\
<input type="checkbox" name="setbox2" value="sb2"> <span style="font-family: monospace">via</span>\
<input type="checkbox" name="setbox3" value="sb3"> weekday (as hidden note)\
<br />\
<br />\
Spacing:\
<br />\
Single line:\
<input type="radio" name="spacebox" id="spacebox1" value="sp1">\
Unspaced\
<input type="radio" name="spacebox" id="spacebox2" value="sp2">\
Spaced\
<br />\
Multiple line:\
<input type="radio" name="spacebox" id="spacebox3" value="sp3">\
Unspaced\
<input type="radio" name="spacebox" id="spacebox4" value="sp4">\
Spaced\
<br />\
<br />\
Ref name style:<br />\
<input type="radio" name="lengthbox" id="lengthbox1" value="lg1">\
<span style="font-family: monospace"><ref name="Wetu691231"></span><br />\
<input type="radio" name="lengthbox" id="lengthbox2" value="lg2">\
<span style="font-family: monospace"><ref name="Wetump19691231p7"></span><br />\
<input type="radio" name="lengthbox" id="lengthbox3" value="lg3">\
<span style="font-family: monospace"><ref name="WetumpkaAr 1969-12-31 p7"></span><br />\
<input type="radio" name="lengthbox" id="lengthbox4" value="lg4">\
<span style="font-family: monospace"><ref name="WetumpkaArgusPi 1969-12-31 p7"></span><br />\
<input type="radio" name="lengthbox" id="lengthbox5" value="lg5">\
<span style="font-family: monospace"><ref name="The Wetumpka Argus-Picayune Weekly 1969-12-31 p7"></span><br />\
<br />\
<b>To close and save configuration, click the "settings" button again.</b>\
</p> \
</div> \
';
async function saveSettings(settingsToSave) {
await GM.setValue("pressPassConfig", JSON.stringify(settingsToSave));
}
function settingsWindow() {
try {
document.getElementsByClassName("navbar")[0].appendChild(setHTML);
// Try to add it to navbar.
} catch(e) {
try {
document.getElementsByClassName("viewer-navbar")[0].appendChild(setHTML);
// Try other thing if that's not on the page.
} catch(e) {
document.getElementsByClassName("LeftContainer")[0].appendChild(setHTML);
// Try other thing if that's not on the page.
} // end inner nested catch
} // end outer nested catch
if (settings['style'] == 1) { document.getElementById("stylebox1").checked = true; }
if (settings['style'] == 2) { document.getElementById("stylebox2").checked = true; }
if (settings['style'] == 3) { document.getElementById("stylebox3").checked = true; }
if (settings['style'] == 4) { document.getElementById("stylebox4").checked = true; }
if (settings['style'] == 5) { document.getElementById("stylebox5").checked = true; }
if (settings['authparse'] == 1) { document.getElementById("authbox1").checked = true; }
if (settings['date'] == 1) { document.getElementById("datefbox1").checked = true; }
if (settings['date'] == 2) { document.getElementById("datefbox2").checked = true; }
if (settings['date'] == 3) { document.getElementById("datefbox3").checked = true; }
if (settings['date'] == 4) { document.getElementById("datefbox4").checked = true; }
if (settings['date'] == 5) { document.getElementById("datefbox5").checked = true; }
if (settings['accdate'] == 1) { document.getElementsByName("setbox1")[0].checked = true; }
if (settings['via'] == 1) { document.getElementsByName("setbox2")[0].checked = true; }
if (settings['week'] == 1) { document.getElementsByName("setbox3")[0].checked = true; }
if ((settings['multi'] == 0) && (settings['spacing'] == 0)) { document.getElementById("spacebox1").checked = true; }
if ((settings['multi'] == 0) && (settings['spacing'] == 1)) { document.getElementById("spacebox2").checked = true; }
if ((settings['multi'] == 1) && (settings['spacing'] == 0)) { document.getElementById("spacebox3").checked = true; }
if ((settings['multi'] == 1) && (settings['spacing'] == 1)) { document.getElementById("spacebox4").checked = true; }
if (settings['length'] == 1) { document.getElementById("lengthbox1").checked = true; }
if (settings['length'] == 2) { document.getElementById("lengthbox2").checked = true; }
if (settings['length'] == 3) { document.getElementById("lengthbox3").checked = true; }
if (settings['length'] == 4) { document.getElementById("lengthbox4").checked = true; }
if (settings['length'] == 5) { document.getElementById("lengthbox5").checked = true; }
}
function settingsClose() {
settings['accdate'] = 0;
settings['via'] = 0;
settings['week'] = 0;
settings['authparse'] = 0;
if (document.getElementById("stylebox1").checked == true) { settings['style'] = 1; }
if (document.getElementById("stylebox2").checked == true) { settings['style'] = 2; }
if (document.getElementById("stylebox3").checked == true) { settings['style'] = 3; }
if (document.getElementById("stylebox4").checked == true) { settings['style'] = 4; }
if (document.getElementById("stylebox5").checked == true) { settings['style'] = 5; }
if (document.getElementById("authbox1").checked == true) { settings['authparse'] = 1; }
if (document.getElementById("datefbox1").checked == true) { settings['date'] = 1; }
if (document.getElementById("datefbox2").checked == true) { settings['date'] = 2; }
if (document.getElementById("datefbox3").checked == true) { settings['date'] = 3; }
if (document.getElementById("datefbox4").checked == true) { settings['date'] = 4; }
if (document.getElementById("datefbox5").checked == true) { settings['date'] = 5; }
if (document.getElementsByName("setbox1")[0].checked == true) {settings['accdate'] = 1; }
if (document.getElementsByName("setbox2")[0].checked == true) {settings['via'] = 1; }
if (document.getElementsByName("setbox3")[0].checked == true) {settings['week'] = 1; }
if (document.getElementById("spacebox1").checked == true) {settings['multi'] = 0; settings['spacing'] = 0; }
if (document.getElementById("spacebox2").checked == true) {settings['multi'] = 0; settings['spacing'] = 1; }
if (document.getElementById("spacebox3").checked == true) {settings['multi'] = 1; settings['spacing'] = 0; }
if (document.getElementById("spacebox4").checked == true) {settings['multi'] = 1; settings['spacing'] = 1; }
if (document.getElementById("lengthbox1").checked == true) { settings['length'] = 1; }
if (document.getElementById("lengthbox2").checked == true) { settings['length'] = 2; }
if (document.getElementById("lengthbox3").checked == true) { settings['length'] = 3; }
if (document.getElementById("lengthbox4").checked == true) { settings['length'] = 4; }
if (document.getElementById("lengthbox5").checked == true) { settings['length'] = 5; }
try {
document.getElementsByClassName("navbar")[0].removeChild(setHTML);
// Try to remove it from navbar.
} catch(e) {
try {
document.getElementsByClassName("viewer-navbar")[0].removeChild(setHTML);
// Try other thing if that's not on the page.
} catch(e) {
document.getElementsByClassName("LeftContainer")[0].removeChild(setHTML);
// Try other thing if that's not on the page.
} // end inner nested catch
} // end outer nested catch
saveSettings(settings);
}
function composeCitation(link, date, page, title, npname, city, week, autharray) {
// Make a reasonably useful ref tag.
// No idea why the hell this ended up being a thing, but strip it out.
npname = npname.replaceAll(" ,", "");
npname = npname.replaceAll(" ", "");
//if (npname.slice(-1) != " ") {
//npname = npname.substring(0, npname.length - 1);
//} // Sometimes this happens, I suppose.
var refTag = npname;
refTag = refTag.replaceAll(/[^\x00-\x7F]/g, "");
// Remove everything that isn't ASCII from the string.
for(asdf of ["~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "-", "=", "{", "[", "}", "]", "|", "\\", ":", ";", '"', "'", "<", ",", ">", ".", "?", "/"]){
refTag = refTag.replaceAll(asdf, " ");
} // Strip out weird stuff that won't go into a ref template name.
// Strip out multiple spaces.
refTag = refTag.replaceAll(" ", " ");
refTag = refTag.replaceAll(" ", " ");
refTag = refTag.replaceAll(" ", " ");
refTag = refTag.replaceAll(" ", " ");
refTag = refTag.replaceAll(" ", " ");
if (settings['length'] != 5) {
refTag = refTag.replace("The", "");
refTag = refTag.replaceAll(" ","");
} // Trim spaces from the newspaper name, unless "enormously long ref tags" option is set.
// Now we ensure that the dreaded "leading digit in a MediaWiki reference name" issue does not come up.
for(var asdf of ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]){
if(refTag.substr(0,1) == asdf){
refTag = "n" + refTag.substr(1);
} // If a number is the first character of the string, replace it with something. How about "n", for "newspaper".
} // Do this for all ten digits.
// Now we pad it out a little, in case the string is short.
// Trim that padded query down to character limit.
if (settings['length'] == 1) {
refTag = refTag.substr(0,4);
}
if (settings['length'] == 2) {
refTag = refTag.substr(0,6);
}
if (settings['length'] == 3) {
refTag = refTag.substr(0,10);
}
if (settings['length'] == 4) {
refTag = refTag.substr(0,15);
}
// Add date format to the ref tag name based on settings.
if (settings['length'] == 1) {
refTag = refTag + date.replaceAll("-","").substring(2);
} // Date for tag format 1: "691231"
if (settings['length'] == 2) {
refTag = refTag + date.replaceAll("-","") + "p" + page;
} // Date for tag format 2: "19691231p7"
if (settings['length'] > 2) {
refTag = refTag + " " + date + " p" + page;
} // Date for tag formats 3, 4, 5: "1969-12-31 p7"
// Today's date.
var todayDate = new Date().toISOString().slice(0, 10);
var monthodate = parseInt(date.substring(5,7));
var monthtoday = parseInt(todayDate.substring(5,7));
// Short months
var moshs = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
var moshd = moshs[monthodate - 1];
var mosht = moshs[monthtoday - 1];
// Long month
var molos = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var molod = molos[monthodate - 1];
var molot = molos[monthtoday - 1];
// Days without padding (i.e. "1" instead of "01")
var sdayd = String(parseInt(date.substring(8,10)));
var sdayt = String(parseInt(todayDate.substring(8,10)));
// Years as strings (quite simple)
var yeard = date.substring(0,4);
var yeart = todayDate.substring(0,4);
// Initialize variables. If settings['date'] is 1, they will just stay like this.
var parsedDate = date;
var parsedToday = todayDate;
// Now we parse the proper date format using the settings.
if (settings['date'] == 2) {
parsedDate = sdayd + " " + molod + " " + yeard;
parsedToday = sdayt + " " + molot + " " + yeart;
}
if (settings['date'] == 3) {
parsedDate = sdayd + " " + moshd + " " + yeard;
parsedToday = sdayt + " " + mosht + " " + yeart;
}
if (settings['date'] == 4) {
parsedDate = moshd + " " + sdayd + ", " + yeard;
parsedToday = mosht + " " + sdayt + ", " + yeart;
}
if (settings['date'] == 5) {
parsedDate = molod + " " + sdayd + ", " + yeard;
parsedToday = molot + " " + sdayt + ", " + yeart;
}
// Sanitize author array (don't allow duplicates).
var auths = []
if(autharray.length > 0){
for(let i = 0; i < autharray.length; i++){
if(!auths.includes(autharray[i])) {
auths.push(autharray[i]);
} // If it doesn't already include it.
} // For every element of autharray
} // If autharray has anything in it -- it might not!
// Compose an actual citation to return.
var ml = settings['multi'];
var reffy = "";
var authstring = "";
// Compose string for authors, if that setting's enabled.
if ((settings['authparse'] == 1) && (auths.length > 0)){
for(let i = 0; i < auths.length; i++){
if (settings['spacing'] == 0) {
authstring += "|author" + String(i + 1) + "=" + auths[i];
}
if (settings['spacing'] == 1) {
authstring += " | author" + String(i + 1) + " = " + auths[i];
}
if (ml == 1) { authstring += "<br />"; }
}
}
// Oct '23: Remove weird proxy URL gunk, if it exists.
link = link.replace("www-newspapers-com.wikipedialibrary.idm.oclc.org", "newspapers.com");
// if (ml == 1) { reffy += "<br />"; }
if (settings['spacing'] == 0) {
reffy += '<ref name="' + refTag + '">' + "{{Cite news";
if (ml == 1) { reffy += "<br />"; }
reffy += "|url=" + link;
if (ml == 1) { reffy += "<br />"; }
reffy += "|date=" + parsedDate;
if (ml == 1) { reffy += "<br />"; }
reffy += "|page=" + page;
if (ml == 1) { reffy += "<br />"; }
reffy += "|title=" + title;
if (ml == 1) { reffy += "<br />"; }
reffy += "|newspaper=" + npname;
if (ml == 1) { reffy += "<br />"; }
reffy += "|location=" + city;
if (ml == 1) { reffy += "<br />"; }
if (settings['via'] == 1) {
reffy += "|via=Newspapers.com";
if (ml == 1) { reffy += "<br />"; }
}
if (settings['accdate'] == 1) {
reffy += "|access-date=" + parsedToday;
if (ml == 1) { reffy += "<br />"; }
}
reffy += authstring;
reffy += "}}</ref>";
if (settings['week'] == 1) {
reffy += "<!-- " + week + " -->"
}
reffy = reffy.replaceAll(" ", " ");
reffy = reffy.replaceAll(" ", " ");
reffy = reffy.replaceAll(" |", "|");
} // If spacing isn't enabled.
if (settings['spacing'] == 1) {
reffy += '<ref name="' + refTag + '">' + "{{Cite news";
if (ml == 1) { reffy += "<br />"; }
reffy += " | url = " + link;
if (ml == 1) { reffy += "<br />"; }
reffy += " | date = " + parsedDate;
if (ml == 1) { reffy += "<br />"; }
reffy += " | page = " + page;
if (ml == 1) { reffy += "<br />"; }
reffy += " | title = " + title;
if (ml == 1) { reffy += "<br />"; }
reffy += " | newspaper = " + npname;
if (ml == 1) { reffy += "<br />"; }
reffy += " | location = " + city;
if (ml == 1) { reffy += "<br />"; }
if (settings['via'] == 1) {
reffy += " | via = Newspapers.com";
if (ml == 1) { reffy += "<br />"; }
}
if (settings['accdate'] == 1) {
reffy += " | access-date = " + parsedToday;
if (ml == 1) { reffy += "<br />"; }
}
reffy += authstring;
reffy += "}}</ref>";
if (settings['week'] == 1) {
reffy += "<!-- " + week + " -->"
}
} // If spacing is enabled.
// Other citation styles (not quite so demanding!)
if (settings['style'] == 1) {
return reffy;
} // EN.WP
if (settings['style'] == 2) {
if (title.slice(-1) != ".") {
title = title + ".";
} // Append period if it's not already ending with one.
if (npname.slice(-1) != ".") {
npname = npname + ",";
} // Append period if it's not already ending with one.
reffy = '“' + title + '” <em>' + npname + "</em> " + sdayd + " " + moshd + ". " + yeard + ", " + link + ". Accessed " + sdayt + " " + mosht + ". " + yeart + ".";
return reffy;
} // MLA9
if (settings['style'] == 3) {
if (title.slice(-1) != ".") {
title = title + ".";
} // Append period if it's not already ending with one.
if (npname.slice(-1) != ".") {
npname = npname + ".";
} // Append period if it's not already ending with one.
reffy = "Newspapers.com. (" + yeard + ", " + molod + " " + sdayd + "). " + title + " <em>" + npname + "</em> Retrieved " + molot + " " + sdayt + ", " + yeart + ", from " + link + "."
return reffy;
} // APA7
if (settings['style'] == 4) {
if (title.slice(-1) != ".") {
title = title + ".";
} // Append period if it's not already ending with one.
if (npname.slice(-1) != ".") {
npname = npname + ".";
} // Append period if it's not already ending with one.
reffy = '“' + title + '” <em>' + npname + "</em> " + molod + " " + sdayd + ", " + yeard + ". " + link + ".";
return reffy;
} // Chicago
if (settings['style'] == 5) {
reffy = "@article{" + title.replaceAll(" ", "-") + "-" + yeard + ", ";
reffy += "title = {" + title + "} ";
reffy += "url = {" + link + "}, ";
reffy += "journal = {" + npname + "}, ";
reffy += "publisher = {Newspapers.com}, ";
reffy += "year = {" + yeard + "}, ";
reffy += "month = {" + moshd + "}, ";
reffy += "day = {" + sdayd + "} ";
reffy += "}"
return reffy;
} // BiBTeX
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// What to do if it's a "search" page is below.
////////////////////////////////////////////////////////////////////////////////////////////////////
if ((window.location.href.indexOf("newspapers.com/search/") >= 0) || (window.location.href.indexOf("www-newspapers-com.wikipedialibrary.idm.oclc.org/search/") >= 0)){
// If we're on a search page at newspapers.com
//alert("Running a script, wow.");
var newHTML = document.createElement ('div');
newHTML.innerHTML = ' \
<div id="gmSomeID"> \
<p><center>\
Auto: <button type="button" id="clickButton" class="clbutton">click</button><button type="button" id="scrollButton" class="scrollButton">scroll</button> \
Select: <button type="button" id="saButton" class="sabutton">all</button><button type="button" id="snButton" class="snbutton">none</button> \
Cites: <button type="button" id="scrapeButton" class="scbutton">make</button><button type="button" id="clearButton" class="clbutton">clear</button> \
New tab: <button type="button" id="openallButton" class="oabutton"><small>selected</small></button><button type="button" id="openeveryButton" class="oebutton">all</button> \
Links: <button type="button" id="newspageButton" class="npbutton"><small> image</small></button> \
Config: <button type="button" id="settingsButton" class="stbutton">settings</button>\
</center></p> \
</div> \
';
// Foolproof, but puts the buttons annoyingly at the very bottom of the page.
//document.getElementsByClassName("sticky-top")[0].appendChild(newHTML);
//document.getElementsByClassName("navbar")[0].appendChild(newHTML);
// Puts it up in the navbar, which is mostly deead space. I kind of like this, but it doesn't stick with you as you scroll.
// Auto: <button type="button" id="clickButton" class="clbutton" style="font-family: monospace"><small>click</small></button><button type="button" id="scrollButton" class="scrollButton" style="font-family: monospace"><small>scroll</small></button>
document.getElementById('primary-filters').appendChild(newHTML);
document.getElementById("clickButton").addEventListener("click", autoClick);
document.getElementById("scrollButton").addEventListener("click", autoScroll);
document.getElementById("saButton").addEventListener("click", checkAll);
document.getElementById("snButton").addEventListener("click", uncheckAll);
document.getElementById("scrapeButton").addEventListener("click", scrapeLinks);
document.getElementById("clearButton").addEventListener("click", clearLinks);
document.getElementById("openallButton").addEventListener("click", openLinks);
document.getElementById("openeveryButton").addEventListener("click", openAllLinks);
document.getElementById("newspageButton").addEventListener("click", toggleLinks);
document.getElementById("settingsButton").addEventListener("click", settingsToggle);
// Add listeners, so that all of the buttons actually do something.
document.getElementById("clickButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("scrollButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("saButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("snButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("scrapeButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("clearButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("openallButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("openeveryButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("newspageButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("settingsButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 7em; font-size:75%";
// Set formatting for the buttons.
var scrollHTML = document.createElement ('div');
scrollHTML.innerHTML = ' \
<div id="gmSomeID"> \
<p><center>\
Auto: <button type="button" id="clickButtonb" class="clbutton" style="font-family: monospace"><small>click</small></button><button type="button" id="scrollButtonb" class="scrollButton" style="font-family: monospace"><small>scroll</small></button>\
</center></p> \
</div> \
';
document.body.appendChild(scrollHTML);
document.getElementById("clickButtonb").addEventListener("click", autoClick);
document.getElementById("scrollButtonb").addEventListener("click", autoScroll);
// Set toggle variable for autoclicker
var autoClickOn = 0;
var autoScrollOn = 0;
var newspageToggle = 0;
// Button HTML, and listener, for checkbox adding. Made unnecessary by the setInterval.
// <button type="button" id="checksButton" class="ckbutton">add checkboxes</button>\
// document.getElementById("checksButton").addEventListener("click", addBoxes);
var boxesID = setInterval(addBoxes, 500);
function toggleLinks() {
if (newspageToggle == 0) {
document.getElementById("newspageButton").innerHTML = "<small>newspage</small>";
var l = document.links;
for(var i=0; i<l.length; i++) {
l[i].href = String(l[i].href).replace("/image/", "/newspage/");
} // For each link in the page.
} // If we're setting it to "newspage".
if (newspageToggle == 1) {
document.getElementById("newspageButton").innerHTML = "<small> image</small>";
var li = document.links;
for(var ii=0; i<li.length; ii++) {
li[ii].href = String(li[ii].href).replace("/newspage/", "/image/");
} // For each link in the page.
} // If we're setting it to "image".
newspageToggle = 1 - newspageToggle;
// Invert the toggle.
}
var intervalID;
function autoClick() {
if (autoClickOn == 0){
intervalID = setInterval(clickOnTheButton, 500);
document.getElementById("clickButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%; color:red";
document.getElementById("clickButtonb").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%; color:red";
}
if (autoClickOn == 1){
clearInterval(intervalID);
document.getElementById("clickButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("clickButtonb").style = "ffont-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
}
// If this is 0, yields 1. If this is 1, yields 0.
autoClickOn = 1 - autoClickOn;
} // Function to click on the thing.
function clickOnTheButton() {
document.querySelector('.btn-block').click();
} // Love to define an entire function to call from the setInterval which I'm defining as a variable inside another function
// That's sarcasm, actually. I don't "love to" do this. But I have to.
// called from the click listener, to execute one line of code.
var intervalScroll;
function autoScroll() {
if (autoScrollOn == 0){
intervalScroll = setInterval(scrollOnTheScreen, 50);
document.getElementById("scrollButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%; color:red";
document.getElementById("scrollButtonb").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%; color:red";
window.scrollBy(0,500);
}
if (autoScrollOn == 1){
clearInterval(intervalScroll);
document.getElementById("scrollButton").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
document.getElementById("scrollButtonb").style = "font-family: monospace; padding: 1px 1px 1px 1px; width: 5em; font-size:75%";
}
// If this is 0, yields 1. If this is 1, yields 0.
autoScrollOn = 1 - autoScrollOn;
} // Function to click on the thing.
function scrollOnTheScreen() {
window.scrollBy(0,15);
} // Same as above.
function addBoxes() {
var as = document.getElementsByClassName('search-record');
var increment = 0;
//alert("Starting");
for(var asdf in as){
increment += 1;
if (as[asdf].getElementsByClassName('czechbox').length != 0) {
var useless = 0;
}
else {
var boxHTML = document.createElement('div');
boxHTML.innerHTML = '<input type="checkbox" id="czechbox" class="czechbox" name="czechbox' + increment + '" value="' + increment + '">';
// Dummy string (just adds the text "hi"):
//boxHTML.innerHTML = '<div id="czechbox" class="czechbox' + increment + '"><p>Hi</p></div>'
//as[asdf].getElementsByClassName('h5')[0].getElementsByTagName('b')[0].appendChild(boxHTML);
// Appending the box HTML to the page number:
//as[asdf].getElementsByClassName('text-uppercase')[0].appendChild(boxHTML);
// Append to the little newspaper icon.
try{as[asdf].getElementsByClassName('icon-paper')[0].appendChild(boxHTML);} catch(error) {console.error(error);}
try{as[asdf].getElementsByClassName('icon-obit')[0].appendChild(boxHTML);} catch(error) {console.error(error);}
//alert(increment);
} // If there isn't a checkbox already there.
} // Iterate over all search-records.
} // Function to add checkboxes (called automatically every so often).
function checkAll() {
// Get every box in the document.
var bice = document.getElementsByClassName('czechbox');
for (var asdf in bice){
bice[asdf].checked = true;
} // Iterate over each box.
} // Function to check all checkboxes.
function uncheckAll() {
// Get every box in the document.
var bice = document.getElementsByClassName('czechbox');
for (var asdf in bice){
bice[asdf].checked = false;
} // Iterate over each box.
} // Function to clear all checkboxes.
function openLink(links, counter, openAll) {
if(counter >= links.length) {return;}
var aLink = links[counter].querySelectorAll('a')[0].href
var checked = String(links[counter].getElementsByClassName('czechbox')[0].checked);
counter = counter + 1;
if ((checked == "true") || (openAll == "true")) {
//alert(counter);
//alert(aLink);
window.open(aLink);
setTimeout(function(){openLink(links, counter, openAll);}, 1000);
} else{
setTimeout(function(){openLink(links, counter, openAll);}, 1);
} //
} // Recursive function: opens the link and then calls itself for the next one.
function openLinks() {
var bice = document.getElementsByClassName('czechbox');
var checkedCount = 0;
for (var asdf in bice) {
if (bice[asdf].checked == true) {
checkedCount += 1;
} // If it's checked.
} // Over each checkbox.
var goAhead = confirm("This is about " + String(checkedCount) + " new tabs. Are you sure about that, buddy?");
// Set first timeout. This will be incremented in the loop later.
var waitTime = 100;
if (goAhead == false){
let useless = 0;
} else {
var as = document.getElementsByClassName('search-record');
openLink(as, 0, "false");
// Invoke the function to open troves of links, and say "false" to "open all of them".
} // if the confirmation was given
} // Function to open all links
function openAllLinks() {
var bice = document.getElementsByClassName('czechbox');
var checkedCount = 0;
for (var asdf in bice) {
checkedCount += 1;
} // Over each checkbox (we don't care if they're checked).
var goAhead = confirm("This is about " + String(checkedCount) + " new tabs. Are you sure about that, pal?");
if (goAhead == false){
let useless = 0;
} else {
var as = document.getElementsByClassName('search-record');
openLink(as, 0, "true");
// Invoke the function to open troves of links, and say "true" to "open all of them".
} // if the confirmation was given
} // Function to open all links'
function clearLinks() {
// This is a really weird way to write this
// But iterating over the whole array didn't work for some reason.
// Whereas this does.
if (document.getElementsByClassName("scrapedResults").length != 0){
do {
document.getElementsByClassName("scrapedResults")[0].remove();
} while (document.getElementsByClassName("scrapedResults").length != 0);
} // If there's a scrapedResults at all
} // Function to clear all cites from the bottom.
function scrapeLinks() {
var stringToPrint = ""
var incrementor = 0;
// This will get the whole "search-record", which includes the image to the left as well.
// Seems to work perfectly fine either way, without having to rewrite any code.
var as = document.getElementsByClassName('search-record');
// This will just get "record-content", which includes only the stuff to the right of the image.
// (It worked fine until I had to incorporate the checkboxes, which are in the left column.)
//var as = document.getElementsByClassName('record-content');
for(var asdf in as){
try {
incrementor += 1;
//var stringy = String(as[asdf].innerHTML);
var checked = String(as[asdf].getElementsByClassName('czechbox')[0].checked);
if (checked == "true"){
//as[asdf].getElementsByClassName('
var aLink = String(as[asdf].querySelectorAll('a')[0].href);
//alert(aLink);
// This is the href for that entire whole block of stuff. We want it!
var paper = String(as[asdf].getElementsByClassName('h5')[0].getElementsByTagName('b')[0].innerHTML);
//alert(paper);
// The name of the newspaper is h5.
var aPage = String(as[asdf].getElementsByClassName('text-uppercase')[0].innerHTML);
//alert(aPage);
// The page number ("Page 69") is going to be the first element with the class name "text-uppercase".
// Leaving the below line as a monument to stupidity.
// aPage = aPage.substring(aPage.indexOf("Page") + 4).trim();
aPage = aPage.replaceAll("Page","").trim();
//alert(aPage);
// Trim the "Paqe" from "Page 69" and remove trailing/leading spaces
aPage = aPage.replaceAll(" · Obituary","");
var aCity = String(as[asdf].getElementsByClassName('text-dark')[0].innerHTML);
//alert(aCity);
// This will look like: <span class="icon-news icon-location2 text-muted"></span> Concord, California
aCity = aCity.substring(aCity.indexOf("</span>") + 7).trim();
//alert(aCity);
// Cut it off after the span tag ends.
// Long, goofy bunch of code that tries to see if it says how many matches there were for the string.
// If there are more than one, it adds them to a string as an edit note on that ref.
// Otherwise, it makes that string nothing.
var match = "XXX";
try {
match = String(as[asdf].getElementsByClassName('mt-auto')[0].innerHTML);
if (match != "") {
// It will be something like "<small>1 of 2 matches on this page.</small>"
match = match.substring(match.indexOf("of ") + 3)
match = match.substring(0, match.indexOf(" matches"))
//alert("'" + match + "'");
} else { match = "XXX"} // If it returns anything at all, else, store "XXX"
} catch(error) {console.error(error)} // Catch error for if it hasn't loaded the "1 of 1 matches on this page" thing yet.
if ((match == "XXX") || (match == "1") || (match == "")) {
match = "";
} else {match = "<!-- M:" + match + " -->";} // Make it a comment.
// The above code makes an editnote to say how many matches there are (if it's more than 1).
//alert(match);
var lastSpan = as[asdf].getElementsByTagName('span').length;
var aDate = String(as[asdf].getElementsByTagName('span')[lastSpan - 1].innerHTML);
// The date ("Sunday, October 07, 2007") is the third "span" in this block of HTML - unless there's that premium icon.
// To avoid stupidity, we're going to just take the last span in the whole block, rather than "2" or "3".
// Below, is a huge ugly chunk of code to format the date properly (YYYY-MM-DD).
var aDay = "XXX";
if (aDate.indexOf("Monday") != -1) { aDay = "Mon"; };
if (aDate.indexOf("Tuesday") != -1) { aDay = "Tue"; };
if (aDate.indexOf("Wednesday") != -1) { aDay = "Wed"; };
if (aDate.indexOf("Thursday") != -1) { aDay = "Thu"; };
if (aDate.indexOf("Friday") != -1) { aDay = "Fri"; };
if (aDate.indexOf("Saturday") != -1) { aDay = "Sat"; };
if (aDate.indexOf("Sunday") != -1) { aDay = "Sun"; };
// Store which day it was as a three-letter day name.
aDate = aDate.replace("Monday, ", "");
aDate = aDate.replace("Tuesday, ", "");
aDate = aDate.replace("Wednesday, ", "");
aDate = aDate.replace("Thursday, ", "");
aDate = aDate.replace("Friday, ", "");
aDate = aDate.replace("Saturday, ", "");
aDate = aDate.replace("Sunday, ", "");
// "Sunday, October 07, 2007" will not parse as a valid date, we have to make it just be the day.
// After this, it will be "October 07, 2007".
aDate = aDate.replace("January ", "01-");
aDate = aDate.replace("February ", "02-");
aDate = aDate.replace("March ", "03-");
aDate = aDate.replace("April ", "04-");
aDate = aDate.replace("May ", "05-");
aDate = aDate.replace("June ", "06-");
aDate = aDate.replace("July ", "07-");
aDate = aDate.replace("August ", "08-");
aDate = aDate.replace("September ", "09-");
aDate = aDate.replace("October ", "10-");
aDate = aDate.replace("November ", "11-");
aDate = aDate.replace("December ", "12-");
// Replace the months with digits.
// After this, it will be "10-07, 2007".
aDate = aDate.substring(aDate.length - 4) + "-" + aDate.substring(0, (aDate.length - 4))
// Overly baroque way of moving the year to the front of the date.
// After this, it will be "2007-10-07, ".
aDate = aDate.replaceAll(",","").trim();
// After this, it will be "2007-10-07".
aDate = aDate.replaceAll(" ", "");
// Replace space.
aDate = aDate.replaceAll(" ", "");
// This is actually a U+2009 THIN SPACE.
// Afer this, it will remove that weird date bug that happens for obituaries sometimes.
//alert(aDate)
let queryString = window.location.href.substring(window.location.href.indexOf("#query=") + 7)
// The current URL, but only the part after the query string.
// Now we are going to come up with a name for the ref titles.
queryString = decodeURIComponent(queryString);
// De-percent-encode the query.
queryString = queryString.replace(/[^\x00-\x7F]/g, "");
// Remove everything that isn't ASCII from the string.
for(asdf of ["~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "-", "=", "{", "[", "}", "]", "|", "\\", ":", ";", '"', "'", "<", ",", ">", ".", "?", "/"]){
queryString = queryString.replaceAll(asdf, "");
} // Strip out weird stuff that won't go into a ref template name.
// Now we ensure that the dreaded "leading digit in a MediaWiki reference name" issue does not come up.
for(asdf of ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]){
if(queryString.substr(0,1) == asdf){
queryString = "n" + queryString.substr(1);
} // If a number is the first character of the string, replace it with something. How about "n", for "newspaper".
} // Do this for all ten digits.
// Now we pad it out a little, in case the query is short.
queryString = queryString + "0000000000";
// Trim that padded query to ten characters.
queryString = queryString.substr(0, 10);
// Commenting this out in favor of the globally defined composeCitation function (2021 Nov 6)
//var citation = '<ref name="' + queryString + ("00000" + incrementor).slice(-5) + '">'
//// Ref name: "scrounge" plus zero-padded five-digit ref identifier
//citation += '{{cite newspaper|url=' + aLink
////citation += '{{cite newspaper|url='
//citation += '|date=' + aDate
//citation += '|page=' + aPage
//citation += '|title=Page ' + aPage
//citation += '|newspaper=' + paper;
//citation += '|location=' + aCity
//citation += '}}</ref>'
//citation += '<!-- ' + aDay + ' -->'
//citation += match;
var aTitle = "Page " + aPage;
var aAuths = [];
// Use compositing function defined elsewhere.
var citation = composeCitation(aLink, aDate, aPage, aTitle, paper, aCity, aDay, aAuths);
// function composeCitation(link, date, page, title, npname, city, week)
//alert(citation);
// ' | publisher = "
// Above is the prim-and-proper vertical cite style.
// Maybe I will add an option to output this later.
// For now? Who cares.
//alert(citation);
//alert(String(as[asdf].getElementsByTagName('span')));
stringToPrint += "<br />\n" + citation;
//alert(String(as[asdf].getElementsByTagName('span')));
} // If the checkbox is checked.
/*
What we're getting from a "record-content" looks like this:
<a href="/image/745226149/?terms=%22bradford%20island%22&match=1" class="d-flex align-self-start flex-column">
<h2 class="h5 mb-1"><b>Daily Transcript</b></h2>
<p class="text-muted text-uppercase text-small mb-1">Page 6</p>
<p class="ml-n1 text-dark mb-1" title="Location"><span class="icon-news icon-location2 text-muted"></span> Concord, California</p>
<p class="ml-n1 mb-1 text-dark"><span class="news-date icon-news icon-cal text-muted mr-1"></span><span>Wednesday, January 06, 1960</span></p>
<p class="text-muted mb-0 mt-auto"><small>1 of 1 matches on this page.</small></p></a>
*/
//alert(String(as[asdf].href));
// "undefined"
//alert(String(as[asdf].innerHTML));
} catch (error) {console.error(error)} // I hate javascript.
} // For each entry in the whole array.
//alert(namesToPrint);
// The next block of code is some goofy stuff to generate edit-note comments for the source. Fairly baroque and pointless.
let queryString = window.location.href.substring(window.location.href.indexOf("#query=") + 7)
// The current URL, but only the part after the query string.
stringToPrint = "<!-- Query: " + queryString +" --><br/>\n" + stringToPrint
let today = new Date().toISOString().slice(0, 10)
stringToPrint += "<br/>\n<!-- Citations generated by JPxG's PressPass v2.1, " + today + " -->"
var stringHTML = document.createElement ('div');
stringHTML.innerHTML = '<span id="scrapedResults" class="scrapedResults" style="font: monospace;">' + stringToPrint + '</div>';
document.body.appendChild(stringHTML);
// This works, but freezes all Javascripts on the page (including loading of previews, etc).
//document.body.innerHTML += stringToPrint;
} // What to do when you clikc the freakin' button.
} // End of what to do if it's a newspapers search page.
////////////////////////////////////////////////////////////////////////////////////////////////////
// What to do if it's a "clip" or "article" page is below.
////////////////////////////////////////////////////////////////////////////////////////////////////
if ((window.location.href.indexOf("newspapers.com/clip/") >= 0) || (window.location.href.indexOf("www-newspapers-com.wikipedialibrary.idm.oclc.org/clip/") >= 0) || (window.location.href.indexOf("newspapers.com/article/") >= 0) || (window.location.href.indexOf("www-newspapers-com.wikipedialibrary.idm.oclc.org/article/") >= 0)) {
function generateFromClip(){
//console.log("asdf");
var cliplink = window.location.href;
//console.log("link logged");
//var cliptitl = document.getElementById("spotTitle").innerHTML;
var cliptitl = document.querySelector('h1[class^="page_Title"]').innerHTML;
//console.log("titl logged");
// var clipdate = document.querySelector('[itemprop=dateCreated]').innerHTML;
var clipdate = document.querySelector('time[datetime][month="short"]').innerHTML;
//console.log(clipdate)
//console.log("date logged");
var clippage = document.querySelector('span[class^="PublicationInfo_Page"]').innerHTML;
//console.log("page logged");
var clipname = document.querySelector('h2[class^="PublicationInfo_Publisher"]').innerHTML;
//console.log("name logged");
var clipcity = document.querySelector('p[class^="PublicationInfo_Location"]').innerHTML;
//console.log("city logged");
// clipdate is something like
// Tue, Aug 31, 1813
// 1111111
// 01234567890123456
// As of June 2024: no it's not
// it has full day names, breaking da script!!!!!
// Grotesque hack for normalizing the days.
clipdate = clipdate.replace("Monday", "Mon");
clipdate = clipdate.replace("Tuesday", "Tue");
clipdate = clipdate.replace("Wednesday", "Wed");
clipdate = clipdate.replace("Thursday", "Thu");
clipdate = clipdate.replace("Friday", "Fri");
clipdate = clipdate.replace("Saturday", "Sat");
clipdate = clipdate.replace("Sunday", "Sun");
//var parsedWk = clipdate.substr(13,3);
var parsedWk = clipdate.substr(0,3);
// Strip out the day name -- not really necessary, but may be useful for debugging.
//clipdate = clipdate.replace("Mon, ","").replace("Tue, ","").replace("Wed, ","").replace("Thu, ","").replace("Fri, ","").replace("Sat, ","").replace("Sun, ","")
// Grotesque, lazy hack for zero-padding the date lol.
clipdate = clipdate.replace(" 1, "," 01, ");
clipdate = clipdate.replace(" 2, "," 02, ");
clipdate = clipdate.replace(" 3, "," 03, ");
clipdate = clipdate.replace(" 4, "," 04, ");
clipdate = clipdate.replace(" 5, "," 05, ");
clipdate = clipdate.replace(" 6, "," 06, ");
clipdate = clipdate.replace(" 7, "," 07, ");
clipdate = clipdate.replace(" 8, "," 08, ");
clipdate = clipdate.replace(" 9, "," 09, ");
//var parsedDy = clipdate.substr(0,2);
var parsedDy = clipdate.substr(9,2);
//alert(parsedDy);
//var parsedYr = clipdate.substr(7,4);
var parsedYr = clipdate.substr(13,4);
//alert(parsedYr);
//alert(parsedWk);
var parsedMn = "FOO";
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
for(var asdf in months) {
if (clipdate.indexOf(months[asdf]) >= 0){
// Take the incrementor and store it as the month.
// Remember to add one, or you are a bozo!
parsedMn = "00" + String(parseInt(asdf)+1);
parsedMn = parsedMn.slice(-2);
} // If it actually finds the darn thing.
} // For every month.
clipdate = parsedYr + "-" + parsedMn + "-" + parsedDy
var clipcity_incision = clipcity.indexOf(" •");
if (clipcity_incision !== -1) {
clipcity = clipcity.slice(0, clipcity_incision);
}
clippage = clippage.replaceAll("Page ","");
var auths = []
var tags = document.querySelectorAll('a[class^="Tags"]');
console.log(tags);
//console.log("boof");