-
Notifications
You must be signed in to change notification settings - Fork 9
/
base.js
1951 lines (1288 loc) · 54 KB
/
base.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
// GLOBAL RESETS AND FIXES
$('body').removeClass("listing-chooser-collapsed");
// FUNCTIONS SECTION
// this function returns our query string variable
function getQueryString(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
// INITIAL VARIABLE CREATION SECTION
// creating the settings variable to use when we update and save settings
var currentSettings = {};
var commentNumber; // For numbering comments
// creating the default settings variable if they havn't saved any settings yet
var defaultSettings = {
"global" : {
"layout" : "list",
"shortcuts" : "show",
"sidebar" : "",
"multis" : "",
"navigate" : "hide"
},
"customization" : {
"layout" : "legacy",
"theme" : "legacy-white",
"color" : "orange",
"icons" : "gray"
},
"list" : {
"split" : "6040",
"columns" : "two",
"limit" : "0"
},
"grid" : {
"columns" : "5",
"nsfw" : "no",
"split" : "6040",
"limit" : "0"
},
"subreddits" : [
{"url" : "www.reddit.com/r/shine/", "layout" : "list"},
{"url" : "www.reddit.com/r/aww/", "layout" : "grid"},
{"url" : "www.reddit.com/r/earthporn/", "layout" : "list"}
],
"multireddits" : [
{"url" : "www.reddit.com/user/evilnight/m/redditunes", "layout" : "grid"},
{"url" : "www.reddit.com/user/Abbigale221/m/moviesandtv", "layout" : "list"}
],
"account" : {
"status" : "shinebright"
},
"message" : "",
"version" : {
"current" : "",
"updateinfo" : "show",
"dismissed" : "no"
}
};
// this creates our variable that stories what today's date is
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
todayIs = curr_month.toString() + curr_date.toString();
// this is the main SHINE base function that runs after we've retrieved or created thier settings
// this sets up the basic global interface
function SHINE(){
currentSettings.account.status = "shinebright";
//console.log(currentSettings);
<<<<<<< HEAD
if(!currentSettings.version){
var changelogSettings = {
"version" : {
"current" : "",
"updateinfo" : "show",
"dismissed" : "no"
}
};
currentSettings = $.extend(currentSettings, changelogSettings);
chrome.storage.local.set({"shine": currentSettings});
=======
if(!currentSettings.version){
var changelogSettings = {
"version" : {
"current" : "",
"updateinfo" : "show",
"dismissed" : "no"
}
};
currentSettings = $.extend(currentSettings, changelogSettings);
chrome.storage.local.set({"shine": currentSettings});
}
if(!currentSettings.customization){
var customizationSettings = {
"customization" : {
"layout" : "legacy",
"theme" : "legacy-white",
"color" : "orange",
"icons" : "gray"
}
};
currentSettings = $.extend(currentSettings, customizationSettings);
chrome.storage.local.set({"shine": currentSettings});
}
if(!currentSettings.global.navigate){
var navigateSettings = {
"global" : {
"navigate" : "hide"
}
};
currentSettings = $.extend(true, currentSettings, navigateSettings);
chrome.storage.local.set({"shine": currentSettings});
}
if(!currentSettings.list.limit || !currentSettings.grid.limit){
var limitSettings = {
"list" : {
"limit" : "0"
},
"grid" : {
"limit" : "0"
}
};
currentSettings = $.extend(true, currentSettings, limitSettings);
chrome.storage.local.set({"shine": currentSettings});
>>>>>>> develop
}
// adding our menu interface
var currentSubreddit = $('head').find('link[rel="canonical"]').attr('href');
if (currentSubreddit != undefined) {
currentSubreddit = currentSubreddit.match(/reddit.com\/r\/\w*\//) ? currentSubreddit.match(/r\/\w*\//)[0] : '';
}
htmlToAdd = ""+
'<div class="dark-background"></div>'+
'<div class="shine-nav">'+
'<div class="shine-menu-button shine-search">'+
'<label>search reddit</label>'+
'</div>'+
'<div class="shine-menu-button shine-settings">'+
'<label>shine settings</label>'+
'</div>';
if( $('body').hasClass("with-listing-chooser") ){
htmlToAdd = htmlToAdd +
'<div class="shine-menu-button shine-multi">'+
'<label>toggle multireddits</label>'+
'</div>';
}
htmlToAdd = htmlToAdd +
'<div class="shine-menu-button shine-sidebar">'+
'<label>toggle sidebar</label>'+
'</div>'+
'<a href="" class="shine-menu-button shine-submit">'+
'<label>post to reddit</label>'+
'</a>'+
'<div class="shine-menu-button shine-navicon">'+
'<span class="lines"></span>'+
'</div>'+
'</div>'+
'<div class="shine-nav-comment">'+
'<div class="shine-menu-button shine-comment-prev">'+
'</div>'+
'<div class="shine-menu-button shine-comment-next">'+
'</div>'+
'</div>'+
'<form action="//www.reddit.com/' + currentSubreddit + 'search" id="shine-search" name="search">'+
'<div class="shine-search-wrapper"><input name="q" placeholder="type here and hit enter" tabindex="20" type="text" id="shine-search-box">'+
'<a href="https://www.reddit.com/wiki/search" title="advanced search: by author, subreddit..."></a>'+
'</div>'+
'<input tabindex="22" type="submit" value="">';
if (currentSubreddit && currentSubreddit.length) {
htmlToAdd = htmlToAdd +
'<label class="currentSubreddit"><input type="checkbox" name="restrict_sr" tabindex="21"> limit to ' + currentSubreddit + '</label>';
}
htmlToAdd = htmlToAdd +
'</form>';
$('body').append(htmlToAdd);
$('#header').append(''+
'<div class="layout-switch">'+
'<svg class="grid-switch" fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M3,11H11V3H3M3,21H11V13H3M13,21H21V13H13M13,3V11H21V3" /></svg>'+
'<svg class="list-switch" fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M3,4H21V8H3V4M3,10H21V14H3V10M3,16H21V20H3V16Z" /></svg>'+
'<svg class="list-side-switch" fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M3,16h8v4H3V16z M3,14h8v-4H3V14z M3,8h8V4H3V8z M13,4v16h8V4H13z"/></svg>'+
'</div>'
);
if( $('.pagename a').attr("href") != undefined ){
$('.shine-submit').attr("href", $('.pagename a').attr("href") + "submit/" );
}else{
$('.shine-submit').attr("href", "/submit/");
}
// moving subscribe button into nav
$('.side .subscribe-button').clone().prependTo(".shine-nav");
$('.shine-nav .subscribe-button .option').addClass("shine-menu-button shine-subscribe");
// HERE WE ADD THE SETTINGS DIV
$('body').append(''+
'<div class="settings-panel">'+
'<div class="settings-tabs">'+
'<div data-settings-panel=".panel-default" class="tab tab-default tab-active">Default Settings</div>'+
'<div data-settings-panel=".panel-theme" class="tab tab-theme">Theme Settings</div>'+
'<div data-settings-panel=".panel-grid" class="tab tab-grid">Grid Settings</div>'+
'<div data-settings-panel=".panel-list" class="tab tab-list">List Settings</div>'+
'</div>'+
'<div class="panel panel-default panel-active">'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-default-view">Default View</label>'+
'<span class="settings-small-print">The default view for most pages.</span>'+
'<select name="settings-default-view" id="settings-default-view">'+
'<option value="list">List View</option>'+
'<option value="grid">Grid View</option>'+
'</select>'+
'</div>'+
'<div class="settings-column-half">'+
'<label for="settings-shortcuts-bar">Shortcuts Bar</label>'+
'<span class="settings-small-print">Hide or show the shortcuts bar at the top.</span>'+
'<select name="settings-shortcuts-bar" id="settings-shortcuts-bar">'+
'<option value="show">Show</option>'+
'<option value="hide">Hide</option>'+
'</select>'+
'</div>'+
'</div>'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-update-info">Show Update Info</label>'+
'<span class="settings-small-print">Display information about the SHINE updates.</span>'+
'<select name="settings-update-info" id="settings-update-info">'+
'<option value="show">Show</option>'+
'<option value="hide">Hide</option>'+
'</select>'+
'</div>'+
'<div class="settings-column-half">'+
'<label for="settings-comment-navigation">Next/Previous Comment Navigation</label>'+
'<span class="settings-small-print">Buttons for navigating comments. You can also use left/right arrow keys.</span>'+
'<select name="settings-comment-navigation" id="settings-comment-navigation">'+
'<option value="hide">Hide</option>'+
'<option value="show">Show</option>'+
'</select>'+
'</div>'+
'</div>'+
'<p>To add or edit subreddit or multireddit defaults, please go to that subreddit or multireddit and click the grid view or list view icon in the top bar. To remove a default from the lists below, click the delete icon.</p>'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label>Subreddit Defaults</label>'+
'<div class="settings-subreddit-defaults"></div>'+
'</div>'+
'<div class="settings-column-half">'+
'<label>Multireddit Defaults</label>'+
'<div class="settings-multireddit-defaults"></div>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="panel panel-theme">'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-main-theme">Main Theme</label>'+
'<span class="settings-small-print">If you are using RES, turn on the Night Mode for dark themes.</span>'+
'<div id="themeselect">'+
'<label class="legacy-white">'+
'<input type="radio" name="settings-main-theme" value="legacy-white">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Legacy White</div>'+
'</label>'+
'<label class="legacy-night">'+
'<input type="radio" name="settings-main-theme" value="legacy-night">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Legacy Night</div>'+
'</label>'+
'<label class="violet">'+
'<input type="radio" name="settings-main-theme" value="violet">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Violet Dark</div>'+
'</label>'+
'<label class="material">'+
'<input type="radio" name="settings-main-theme" value="material">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Material Dark</div>'+
'</label>'+
'<label class="blue">'+
'<input type="radio" name="settings-main-theme" value="blue">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Night Time</div>'+
'</label>'+
'<label class="brown">'+
'<input type="radio" name="settings-main-theme" value="brown">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Milk Chocolate</div>'+
'</label>'+
'<label class="gray">'+
'<input type="radio" name="settings-main-theme" value="gray">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Pale Gray</div>'+
'</label>'+
'<label class="dark">'+
'<input type="radio" name="settings-main-theme" value="dark">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Mono Dark</div>'+
'</label>'+
'<label class="black">'+
'<input type="radio" name="settings-main-theme" value="black">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Pure Black</div>'+
'</label>'+
'<label class="modernwhite">'+
'<input type="radio" name="settings-main-theme" value="modernwhite">'+
'<div class="foreground"><span>Aa</span>'+
'<div class="background"></div>'+
'<div class="secondary"></div>'+
'</div>'+
'<div class="theme-name">Modern White</div>'+
'</label>'+
'</div>'+
'</div>'+
'<div class="settings-column-half">'+
'<label for="settings-color-theme">Color Selector</label>'+
'<span class="settings-small-print">Pick your color accent.</span>'+
'<div id="colorselect">'+
'<label class="color red">'+
'<input type="radio" name="settings-color-theme" value="red">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color orange">'+
'<input type="radio" name="settings-color-theme" value="orange">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color amber">'+
'<input type="radio" name="settings-color-theme" value="amber">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color yellow">'+
'<input type="radio" name="settings-color-theme" value="yellow">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color lime">'+
'<input type="radio" name="settings-color-theme" value="lime">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color greenlight">'+
'<input type="radio" name="settings-color-theme" value="greenlight">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color teal">'+
'<input type="radio" name="settings-color-theme" value="teal">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color cyan">'+
'<input type="radio" name="settings-color-theme" value="cyan">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color blue">'+
'<input type="radio" name="settings-color-theme" value="blue">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color indigo">'+
'<input type="radio" name="settings-color-theme" value="indigo">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color purple">'+
'<input type="radio" name="settings-color-theme" value="purple">'+
'<div class="button"><span></span></div>'+
'</label>'+
'<label class="color pink">'+
'<input type="radio" name="settings-color-theme" value="pink">'+
'<div class="button"><span></span></div>'+
'</label>'+
'</div>'+
'<label for="settings-layout-switch">List View Design</label>'+
'<span class="settings-small-print">Select your desired design.</span>'+
'<select name="settings-layout-switch" id="settings-layout-switch">'+
'<option value="legacy">Cards (legacy)</option>'+
'<option value="modern">Flat (modern)</option>'+
'</select>'+
'<label for="settings-color-switch">Icon type for posts</label>'+
'<span class="settings-small-print">This little setting will add more color to your theme.</span>'+
'<select name="settings-color-switch" id="settings-color-switch">'+
'<option value="gray">Grayscale</option>'+
'<option value="color">Colorful</option>'+
'<option value="accent">Color-accented</option>'+
'<option value="lines">Linear</option>'+
'</select>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="panel panel-grid">'+
'<p>The settings below are applied to all Grid View pages.</p>'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-number-columns">Number of Columns</label>'+
'<select name="settings-number-columns" id="settings-number-columns">'+
'<option value="1">One</option>'+
'<option value="2">Two</option>'+
'<option value="3">Three</option>'+
'<option value="4">Four</option>'+
'<option value="5">Five</option>'+
'<option value="6">Six</option>'+
'<option value="7">Seven</option>'+
'<option value="8">Eight</option>'+
'<option value="9">Nine</option>'+
'</select>'+
'</div>'+
'<div class="settings-column-half">'+
'<label for="settings-grid-split">Image & Comments Split Percentage</label>'+
'<select name="settings-grid-split" id="settings-grid-split">'+
'<option value="7030">70 / 30</option>'+
'<option value="6040">60 / 40</option>'+
'<option value="5050">50 / 50</option>'+
'<option value="4060">40 / 60</option>'+
'<option value="3070">30 / 70</option>'+
'</select>'+
'</div>'+
'</div>'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-grid-limit">Limit Infinite Loading</label>'+
'<select name="settings-grid-limit" id="settings-grid-limit">'+
'<option value="0">No limits</option>'+
'<option value="100">Limit over 100</option>'+
'<option value="250">Limit over 250</option>'+
'<option value="500">Limit over 500</option>'+
'<option value="1000">Limit over 1000</option>'+
'</select>'+
'</div>'+
'<div class="settings-column-half">'+
'<label for="settings-show-nsfw">Show NSFW Automatically</label>'+
'<select name="settings-show-nsfw" id="settings-show-nsfw">'+
'<option value="no">No</option>'+
'<option value="yes">Yes</option>'+
'</select>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="panel panel-list">'+
'<p>The settings below are applied to all List View pages.</p>'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-list-layout">List View Layout</label>'+
'<select name="settings-list-layout" id="settings-list-layout">'+
'<option value="one">Display content underneath list item.</option>'+
'<option value="two">Display content to the right of list items.</option>'+
'</select>'+
'</div>'+
'<div class="settings-column-half">'+
'<label for="settings-list-split">Image & Comments Split Percentage</label>'+
'<select name="settings-list-split" id="settings-list-split">'+
'<option value="7030">70 / 30</option>'+
'<option value="6040">60 / 40</option>'+
'<option value="5050">50 / 50</option>'+
'<option value="4060">40 / 60</option>'+
'<option value="3070">30 / 70</option>'+
'</select>'+
'</div>'+
'</div>'+
'<div class="settings-halves">'+
'<div class="settings-column-half">'+
'<label for="settings-list-limit">Limit Infinite Loading</label>'+
'<select name="settings-list-limit" id="settings-list-limit">'+
'<option value="0">No limits</option>'+
'<option value="100">Limit over 100</option>'+
'<option value="250">Limit over 250</option>'+
'<option value="500">Limit over 500</option>'+
'<option value="1000">Limit over 1000</option>'+
'</select>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="settings-saved">Your settings have been saved.</div>'+
'</div>'
);
$('body').append(''+
'<div class="changelog-panel">'+
'<div class="update">'+
'<h2>SHINE for Reddit (unofficial) by vhs (u/voythas)</h2>'+
'<h3>Version 1.6.0</h3>'+
'<ul class="updates">'+
'<li class="new">New design for list view - flat (go to customization options)</li>'+
'<li class="new">Post icons style selector (4 styles to choose from)</li>'+
'<li class="new">Next/Previous comment navigation, you can turn it on in Shine Settings (turning it on for first time requires refreshing the page)</li>'+
'<li class="new">Use arrow left and right for next and previous comment navigation</li>'+
'<li class="new">Added possibility to limit loading of next items for each view (turn it on if Shine is eating too much RAM for you)</li>'+
'<li class="new">New white theme</li>'+
'<li class="new">Three new colors</li>'+
'<li class="enh">Search in Shine now allows to limit search to current subreddit</li>'+
'<li class="enh">Breadcrumbs are now moved to the top</li>'+
'<li class="enh">Colors are now redone, more vibrant and better looking in most cases</li>'+
'<li class="enh">Upvote/Downvote arrows should be more visible now in all themes</li>'+
'<li class="enh">Replaced old jQuery lib with proper one.</li>'+
'<li class="enh">Your username should be more visible now on top</li>'+
'<li class="fix">MaterialDesignIcons should load without delay (lib is now included)</li>'+
'<li class="fix">Fixed numbering of posts</li>'+
'<li class="fix">Fixed hover effect on view chooser</li>'+
'<li class="rem">Removed recommended subreddit ad</li>'+
'<li class="bug">Known bugs: Old Nightmode style is still unfinished, I\'m really sorry! I\'ll get to it as next task.</li>'+
'<li class="bug">Known bugs: Due to changes and cleanups in settings, your theme might reset to default one, sorry but this had to be done.</li>'+
'</ul>'+
'<h3>Version 1.5.0</h3>'+
'<ul class="updates">'+
'<li class="new">Theme and color selector</li>'+
'<li class="new">Support for clips.twitch.tv (both grid and list)</li>'+
'<li class="new">Support for few NSFW sources: pornhub.com, xhamster.com and xvideos.com (list view only for now)</li>'+
'<li class="new">This neat little window and updates notifications (you can disable them in options if you find this annoying)</li>'+
'<li class="enh">Third view type is now accessible without going to the options</li>'+
'<li class="enh">"Hide Child Comments" should be more accessible in side comments view</li>'+
'<li class="enh">Many icons were changed and should be more crips now</li>'+
'<li class="enh">Replaced post icons to a themeable versions</li>'+
'<li class="enh">v.redd.it support for Grid</li>'+
'<li class="enh">It\'s now possible to select more columns in grid mode</li>'+
'<li class="enh">Changed lines icon to Reddit Snu</li>'+
'<li class="enh">Replaced SHINE text with Reddit Snu</li>'+
'<li class="enh">Small animation on hover</li>'+
'<li class="enh">A bit more color integration with RES</li>'+
'<li class="fix">Vimeo in grid mode is now fixed</li>'+
'<li class="fix">Facebook image fixes</li>'+
'<li class="fix">Small margin fixes for Firefox</li>'+
'<li class="fix">Premium features unlocked for everyone</li>'+
'<li class="fix">A lot of other fixes I can\'t really remember now</li>'+
'<li class="rem">Removed Clean Dark Theme</li>'+
'<li class="rem">All SVG files got removed</li>'+
'<li class="rem">All unnecessary files were removed (jpg pictures and stuff)</li>'+
'<li class="bug">Known bugs: Due to many changes, old nightmode (Legacy Night) is not looking as it should, I\'m really sorry, it will be fixed in next version. Please, use any other black themes for now.</li>'+
'</ul>'+
'<h3>Version 1.4.5.5</h3>'+
'<ul class="updates">'+
'<li class="new">Support for streamable.com (thanks to u/itzblitz94)</li>'+
'<li class="new">Support for v.redd.it (list view only)</li>'+
'<li class="new">Clean Dark theme added</li>'+
'<li class="new">Premium features unlocked</li>'+
'<li class="fix">Fixed Imgur loading</li>'+
'<li class="rem">Removed Google Analytics</li>'+
'</ul>'+
'</div>'+
'</div>'
);
/* COMMENT NAVIGATION */
if( currentSettings.global.navigate == "show" ){
$('html').addClass("show-comment-navigation");
$('#settings-comment-navigation').val("show");
}
/* MOAR COLOR */
if( currentSettings.customization.icons == "color" ){
$('html').addClass("colorful");
$('#settings-color-switch').val("color");
}else if( currentSettings.customization.icons == "lines" ){
$('html').addClass("colorlines");
$('#settings-color-switch').val("lines");
}else if( currentSettings.customization.icons == "accent" ){
$('html').addClass("accent");
$('#settings-color-switch').val("accent");
} else {
$('#settings-color-switch').val("gray");
}
/* SETTINGS BAR */
if( currentSettings.global.shortcuts == "hide" ){
$('#settings-shortcuts-bar').val("hide");
}else{
$('html').addClass("show-shortcuts");
}
if( currentSettings.customization.layout == "modern" ){
$('html').addClass("modern-layout");
$('#settings-layout-switch').val("modern");
}
$('#settings-list-limit').val(currentSettings.list.limit);
$('body').attr('data-list-limit', currentSettings.list.limit);
$('#settings-grid-limit').val(currentSettings.grid.limit);
$('body').attr('data-grid-limit', currentSettings.grid.limit);
/* UPDATE INFO */
if( currentSettings.version.updateinfo == "hide" ){
$('#settings-update-info').val("hide");
}
/* DEFAULT VIEW */
if( currentSettings.global.layout == "list" ){
$('#settings-default-view').val("list");
}else{
$('#settings-default-view').val("grid");
}
/* GRID COLUMNS */
$('#settings-number-columns').val( currentSettings.grid.columns );
/* NIGHT MODE */
//$('#settings-main-theme').val( currentSettings.global.night );
$('input[type="radio"][name="settings-main-theme"][value="'+currentSettings.customization.theme+'"]').attr('checked', true);
/* COLOR THEME */
//$('input[type=radio][name=settings-color-theme]:checked').val( currentSettings.customization.color );
$('input[type="radio"][name="settings-color-theme"][value="'+currentSettings.customization.color+'"]').attr('checked', true);
/* NSFW */
$('#settings-show-nsfw').val( currentSettings.grid.nsfw );
/* LIST VIEW */
$('#settings-list-layout').val( currentSettings.list.columns );
/* GRID SPLIT */
if( currentSettings.grid.split == "7030" || currentSettings.grid.split == "6040" || currentSettings.grid.split == "5050" || currentSettings.grid.split == "4060" || currentSettings.grid.split == "3070"){
$('#settings-grid-split').val( currentSettings.grid.split );
}
/* LIST SPLIT */
if( currentSettings.list.split == "7030" || currentSettings.list.split == "6040" || currentSettings.list.split == "5050" || currentSettings.list.split == "4060" || currentSettings.list.split == "3070"){
$('#settings-list-split').val( currentSettings.list.split );
}
if( currentSettings.customization.theme == undefined || currentSettings.customization.theme == "" ){
if (currentSettings.customization.night == "on") {
currentSettings.customization.theme = "legacy-night";
} else {
currentSettings.customization.theme = "legacy-white";
}
}
// this adds the nightmode class
if( currentSettings.customization.theme == "legacy-night" ){
clearThemes();
$('html, body').addClass("res-nightmode");
}else if( currentSettings.customization.theme == "legacy-white" ){
clearThemes();
}else if( currentSettings.customization.theme == "modernwhite" ){
clearThemes();
$('html, body').addClass("lightmode theme-"+currentSettings.customization.theme);
}else{
clearThemes();
$('html, body').addClass("res-nightmode theme-"+currentSettings.customization.theme);
}
// this adds the nightmode class
if( currentSettings.customization.color == undefined || currentSettings.customization.color == "" ){
$('html, body').addClass("color-orange");
currentSettings.customization.color = "orange";
}else{
$('html, body').addClass("color-"+currentSettings.customization.color);
}
// this adds hide nsfw class
if( currentSettings.grid.nsfw == "no" ){
$('html').addClass("shine-hide-nsfw");
}
// this adds a class to the html that says if we've paid or not
$('html').addClass( currentSettings.account.status );
// this adds the sidebar class and multireddit class
$('html').addClass( currentSettings.global.sidebar );
if( $('body').hasClass("with-listing-chooser") ){
$('html').addClass( currentSettings.global.multis );
}
// this cleans up the top right section
if( !$('body').hasClass("loggedin") ){
$('#header-bottom-right .user').contents().first().remove();
$('#header-bottom-right .user').contents().last().remove();
}
// this makes sure we're on the home page, a subreddit, or a multireddit
if( $('body').hasClass("listing-page") && !$('body').hasClass("profile-page") && $('#header-bottom-left .pagename').html() != "preferences" && !$('body').hasClass("subreddits-page") ){
//time to decide if we're going to load the list view or the grid view
var whichView = "";
//time to check the subreddits
if( currentSettings.subreddits.length > 0){
for(i = 0; i < currentSettings.subreddits.length; i++){
windowLocation = $('.pagename a').attr("href");
subredditURL = currentSettings.subreddits[i].url;
if( windowLocation != undefined ){
if( windowLocation.indexOf( subredditURL ) != -1 ){
whichView = currentSettings.subreddits[i].layout;
}
}
displayURL = currentSettings.subreddits[i].url;
displayURL = displayURL.replace("www.reddit.com","");
$('.settings-subreddit-defaults').append('<li data-url="' + currentSettings.subreddits[i].url + '"><a href="http://' + currentSettings.subreddits[i].url + '">' + displayURL + '</a><span data-url="' + currentSettings.subreddits[i].url + '" class="remove-default remove-subreddit-default"></span><span class="default-view">' + currentSettings.subreddits[i].layout + ' view</span></li>');
}
}
// now it's time to check the multireddits
if( currentSettings.multireddits.length > 0){
for(i = 0; i < currentSettings.multireddits.length; i++){
windowLocation = $('.pagename a').attr("href");
multiredditURL = currentSettings.multireddits[i].url;
if( windowLocation != undefined ){
if( windowLocation.indexOf( multiredditURL ) != -1 ){
whichView = currentSettings.multireddits[i].layout;
}
}
displayURL = currentSettings.multireddits[i].url;
displayURL = displayURL.replace("www.reddit.com/user","").replace("www.reddit.com/me","");
$('.settings-multireddit-defaults').append('<li data-url="' + currentSettings.multireddits[i].url + '"><a href="http://' + currentSettings.multireddits[i].url + '">' + displayURL + '</a><span data-url="' + currentSettings.multireddits[i].url + '" class="remove-default remove-multireddit-default"></span><span class="default-view">' + currentSettings.multireddits[i].layout + ' view</span></li>');
}
}
// if whichView is still blank, use the default layout
if( whichView == "" ){
whichView = currentSettings.global.layout;
}
// time to load our other javascript files
if( whichView == "grid" ){
$.getScript( chrome.extension.getURL("jquery.zoom.min.js") );
$.getScript( chrome.extension.getURL("shine-grid.js") );
thingWidth = screen.width / ( parseInt(currentSettings.grid.columns) + 1);
$('html').attr("data-columns", currentSettings.grid.columns);
$('head').append(''+
'<style id="shine-card-width" type="text/css">'+
'html.SHINE.shine-grid body > .content #siteTable .thing{'+
'width:' + thingWidth + 'px;'+
'}'+
'html.SHINE.shine-grid body > .content #siteTable .thing .preview{'+
'width:' + thingWidth + 'px;'+
'flex-basis:' + thingWidth + 'px;'+
'}'+
'</style>'
);
if( currentSettings.grid.split == "7030" || currentSettings.grid.split == "6040" || currentSettings.grid.split == "5050" || currentSettings.grid.split == "4060" || currentSettings.grid.split == "3070"){
$('html').addClass("shine-splitheme-" + currentSettings.grid.split);
}
}else if( whichView == "list" ){
if(currentSettings.list.columns == "two"){
$('html').addClass("shine-list-classic");
}
$.getScript( chrome.extension.getURL("jquery.zoom.min.js") );
$.getScript( chrome.extension.getURL("shine-list.js") );
if(currentSettings.list.split == "7030" || currentSettings.list.split == "6040" || currentSettings.list.split == "5050" || currentSettings.list.split == "4060" || currentSettings.list.split == "3070"){
if( !$('html').hasClass("shine-list-classic") ){
$('html').addClass("shine-split-" + currentSettings.list.split);
}
}
}
// add our view class to the html
$('html').addClass("shine-" + whichView);
}else{
// if we're not on a content page, then load SHINE's default interface
$('html').addClass("shine-default shine-ready");
}
// remove subreddit styling
headLinks = $('head link');
for(i = 0;i<headLinks.length;i++){
if( $(headLinks[i]).attr("title") == "applied_subreddit_stylesheet" ){
subredditCss = $(headLinks[i]).attr("href");
$(headLinks[i]).remove();
}
}
$('html').addClass("SHINE");
if (currentSettings.version.current == undefined) {
currentSettings.version.current = "1.4.5.5";
chrome.storage.local.set({"shine": currentSettings});
}
var manifest = chrome.runtime.getManifest();
var shineVersion = manifest.version;
$('body').append(''+
'<div class="update-info">'+
'<div class="update-info-content">'+
'SHINE got updated to version '+ shineVersion +
'<span class="open-changelog">CHANGELOG</span>'+
'<span class="dismiss-changelog"></span>'+
'</div>'+
'</div>'
);
if (currentSettings.version.current != shineVersion && currentSettings.version.updateinfo != "hide") {
console.info('JUST UPDATED! Old version:' + currentSettings.version.current);
console.info('JUST UPDATED! New version:' + shineVersion);
currentSettings.version.dismissed = "no";
currentSettings.version.current = shineVersion;
chrome.storage.local.set({"shine": currentSettings});
$('.update-info').fadeIn('fast');
} else if (currentSettings.version.current == shineVersion && currentSettings.version.updateinfo != "hide" && currentSettings.version.dismissed != "yes"){
$('.update-info').show();
}