-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsg_enhancement_addon_base.js
1173 lines (990 loc) · 58 KB
/
sg_enhancement_addon_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
/* SGE addon - This a user-script that provides extra functionallity on top of steamgifts.com
Copyright (C) 2012 Rossen Georgiev
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
(function($) {
// chrome/opera hack;
var unsafeWindow = this['unsafeWindow'] || window;
// check if already loaded
if(unsafeWindow.gafIsLoaded) return false;
unsafeWindow.gafIsLoaded = true;
// doesnt load on search page
if(window.location.href.indexOf("search/") > -1 ) return false;
// make sure we only load the code on supported pages
// --------
// This was functionality was moved from the init script.
// Adding support for certain parts of the site will no longer require an action on the user side
if(!window.location.href.match(/^https?\:\/\/www\.steamgifts\.com\/?(#|(open|new|forum).*)?$/))
if(typeof unsafeWindow.gafDev === 'undefined') return false;
// load DLC database
$('body').append('<script type="text/javascript" src="http://rossengeorgiev.github.com/sg-enhancement-addon/sg_dlc_database.json"></script>');
// fades background and shows+centre the popup
unsafeWindow.gafPopupShow = function() {
$("#gafPopup").css({
"top": document.documentElement.clientHeight / 2 - 150,
"left": document.documentElement.clientWidth / 2 - 200
});
$('#gafPopup').fadeIn('slow');
$('#gafPopupBackground').fadeIn('normal');
}
// hide popup and background
unsafeWindow.gafPopupHide = function() {
$('#gafOverlay').remove();
$('#gafPopup').fadeOut('normal');
$('#gafPopupBackground').fadeOut('slow');
$('.ajax_gifts>div.post.quickview').removeClass('quickview');
}
// function is called everytime there is a change to textarea for the filter
// and contents mirrored in the cookie
unsafeWindow.gafFormUpdate = function() {
unsafeWindow.localStorage.gafFilter = $('#gafFilterInput').val();
unsafeWindow.gafFilter = $('#gafFilterInput').val().split(',');
}
// called then ignore button is pressed
// * adds name of the game to the filter and updates the cookie
// * hides all giveaways for the same game
// * slide up animantion
unsafeWindow.gafIgnore = function(elm) {
var node = elm.parentNode.parentNode.parentNode.parentNode;
$(elm).hide();
$('#gafFilterInput').append(',' + $(node).find('.title').find('a').html());
unsafeWindow.gafFormUpdate();
unsafeWindow.gafApplyFilter($('.ajax_gifts>div.post'));
unsafeWindow.gafLoadingCheck();
}
// removes giveaway matching the filter
unsafeWindow.gafApplyFilter = function(gafs) {
// quick search
if($.trim($('input[name=gafSearch]').val()) != "") {
var match_pat = new RegExp($.trim($('input[name=gafSearch]').val()).replace(/[-[\]{}()+?.,\\^$|#\s]/g, '\\$&'),'i');
$(gafs).find('.title a').each(function(k,e) {
if($(e).text().match(match_pat)) {
$(e).parent().parent().parent().stop(true,true).slideDown();
} else {
$(e).parent().parent().parent().stop(true,true).slideUp();
}
});
setTimeout(unsafeWindow.gafLoadingCheck, 1000);
return false;
}
var fall = $('#sg_fid0').is(':checked');
var fftr = $('#sg_fid1').is(':checked');
var fwish = $('#sg_fid2').is(':checked');
var ffade = $('#sg_fid3').is(':checked');
var fpts = $('#sg_fid4').is(':checked');
var fdlc = $('#sg_fid5').is(':checked');
var freg = $('#sg_fid6').is(':checked');
var fgrp = $('#sg_fid7').is(':checked');
var fgreen = $('#sg_fid8').is(':checked');
var fred = $('#sg_fid9').is(':checked');
var fcont_min = parseFloat($('#gafViewLinks .price.min').text().replace('$',''));
var fcont_max = parseFloat($('#gafViewLinks .price.max').text().replace('$',''));
// show all giveaways
if(fall) {
gafs = $(gafs).filter(':hidden');
gafs.find('.description').attr('style','');
gafs.slice(0,5).slideDown(function() {
gafs.slice(5).show();
});
return true;
}
var finalset = []; // final set of giveways that will be displayed
var fgafs = [] // filtered set of giveaways, source for other filters
// filter already owned or ignored giveaways
if(fftr || fwish) {
var gaflist = $.unique(unsafeWindow.gafFilter.concat(unsafeWindow.gafSyncFilter).sort());
var gafstr;
// when the list is empty, additional filtering like for contributor giveaways doenst work
// this this is because, the code block for the second block doesnt execture
gaflist.push('_______'); // quick fix fake entry
// remove all DLC for games we dont own
if(fdlc) $.merge(gaflist, unsafeWindow.gafDLCSyncd);
fgafs = $(gafs).map(function(i,giveaway) {
var elm = $(giveaway).find('a')[0];
$(giveaway).find('.description').attr('style','');
match = false;
for(j = 0; j < gaflist.length; j++) {
gafstr = $.trim(gaflist[j]).toLowerCase().replace(/&/g,'&');
if(gafstr == "") continue;
// check if we are parsing a highlight entry
var highlight = false;
if(gafstr.match(/^\d+\. /)) {
highlight = true;
gafstr = gafstr.replace(/^\d+\. /,'');
}
var pat = new RegExp('^'+gafstr.replace(/[\_\-\[\]{}()+?.,\\^$|#\s]/g, '\\$&').replace(/\*/g,'.*')+'$');
if(highlight) {
// if element doenst match continue with next one
if(!elm.innerHTML.toLowerCase().match(pat)) continue;
// else highlight the element and make it visible
$(giveaway).find('.description').css({background: '#aaFFa8'});
if(fwish)
return giveaway; // append fgafs with highlighted giveway, if highlighted is enabled (fwish)
}
else if(elm.innerHTML.toLowerCase().match(pat))
{
match = true;
break;
}
}
if(!match && fftr) return giveaway; // append giveaway if not in filter list
}).get();
} else {
fgafs = $(gafs).find('.description').attr('style','').parent().parent().get();
}
// filter finalset by number of points
if(fpts) {
// need to get current number of points, if logged in
var p = $('#navigation li a.arrow').slice(1,2).text().match(/\-?(\d+)P/);
if(!p) return false;
else p = parseInt(p[1]);
if(p < 0) return false;
fgafs = $(fgafs).find('.title span').map(function(i,e) {
var s = e.innerHTML.match(/(\d+)P/);
if(s) {
if(s && parseInt(s[1]) <= p)
return $(e).parent().parent().parent().get();
}
}).get();
}
// include contributor giveaways
if(ffade) {
fgafs = $(fgafs).filter(':not(.fade)').get();
}
// include group giveaways
if(fgrp) {
// subset of group giveaways
var tmp = $(fgafs).find('.group_only').parent().parent().parent();
// susbet of tmp of red contributor giveways
var subset = tmp.find('.contributor_only:not(.green)').parent().parent().parent();
// subtract sets
$.merge(finalset, $.grep(tmp, function(e) { return $.inArray(e, subset) == -1 }));
}
// include contributor giveaways
if(fgreen) {
$.merge(finalset, $(fgafs).find('.contributor_only.green').parent().parent().parent().get());
}
if(fred) {
$.merge(finalset, $(fgafs).find('.contributor_only:not(.green)').parent().parent().parent().get());
}
// contributor range
finalset = $.grep(finalset, function(e) {
e = $(e);
if(e.find('.contributor_only').length > 0) {
var amount = parseFloat(e.find('.contributor_only').text().match(/[0-9\.,]+/)[0]);
return (amount >= fcont_min) && (amount <= fcont_max); // apply contributor range
}
return true;
}, false);
// include regular giveaways
if(freg) {
$.merge(finalset, $(fgafs).map(function(i,e) {
if($(e).find('.group_only,.contributor_only').length == 0) {
return e;
}
}).get());
}
// allways show developer giveaways on top
$.merge(finalset, $(".content>.post .new:contains('Developer')").parent().parent().parent().get());
//---------------------
// Filters end
//---------------------
// finalize finalset
// if no filters are selected simply output the whole list
if(!fgreen && !fred && !fgrp && !freg) finalset = fgafs;
else finalset = $.unique(finalset);
// excludeset consists of only giveaways that should be hidden
var excludeset = $(gafs).map(function() {
if( $.inArray(this,finalset) < 0) {
return this;
}
}).get();
// display results :)
excludeset = $(excludeset).filter(':visible');
finalset = $(finalset).filter(':hidden');
excludeset.slice(0,5).stop(true,true).slideUp(function() {
excludeset.slice(5).stop(true,true).hide();
});
finalset.slice(0,5).stop(true,true).slideDown(function() {
finalset.slice(5).stop(true,true).show();
});
}
// add ignore buttons to all giveaways :)
unsafeWindow.gafAddIgnoreButton = function(elms) {
var gafs = $(elms).find('a');
for(i = 0; i < gafs.length; i++) {
if(gafs[i].href.match(/\/giveaway.*?entries$/))
{
$(gafs[i].parentNode.parentNode).append("<span style='margin-right: 10px;'><a href='#' name='gafbutton' onclick='javascript: gafIgnore(this); return false'>Ignore</a></span>")
}
}
}
// function is called by iframe onLoad
// filters new giveaways and adds them to the current page for endless scroll
unsafeWindow.gafPageLoaded = function(data) {
if(data == '') {
return;
} else {
var loadedContent = $(data);
}
if(window.location.href.match(/forum/)) {
if(unsafeWindow.gafHrefPart.length > 5) {
unsafeWindow.gafAddHC(loadedContent);
if(unsafeWindow.gafReverse) {
loadedContent.find('.parent_container').reverse().insertAfter($('.parent_container').last());
}
else {
loadedContent.find('.parent_container').insertAfter($('.parent_container').last());
}
// restore click functionallity
// code taken from SG, credit: CG
$('.delete_comment').click(function(){
$("input[name='delete_comment_id']").val($(this).parent().attr("rel"));
$('#delete_comment').submit();
return false;
});
$('.comment_reply .edit_comment').click(function(){
$(this).parent().parent().parent().children('.user_body').hide();
$(this).parent().parent().parent().children('.user_edit').show();
return false;
});
$('.comment_reply .reply_link a').click(function(){
id=$(this).attr('rel');
depth=parseInt($(this).attr('class'))+1;
$("#comment_form #parent_id").val(id);
$("span.title").html("Add a reply");
$("span.cancel").show();
$("#comment_form").insertAfter('.comment#' + id);
$("#comment_form").addClass('border_container');
return false;
});
$('#comment_form span.cancel a').click(function(){
$("#comment_form #parent_id").val(0);
$("span.title").html("Add a comment");
$("span.cancel").hide();
$("#comment_form").insertAfter('#comment_location');
$("#comment_form").removeClass('border_container');
return false;
});
$('.cancel_edit_comment').click(function(){
$(this).parent().parent().parent().parent().children('.user_body').show();
$(this).parent().parent().parent().parent().children('.user_edit').hide();
return false;
});
}
else {
loadedContent.find('.row a').each(function(key,obj) {
if($(obj).attr('href').match(/^\/forum/)) {
var newURL = $(obj).attr('href') + "/page/31337";
$(obj).attr('href',newURL);
}
});
loadedContent.find('.row').appendTo('.discussions');
$('.row').css({padding: $('#gafSlider').slider("value") + "px 0"});
}
}
else
{
// remove Contributor links from loaded elements
// get all giveaways
var elms = loadedContent.find('.ajax_gifts>div.post');
// update points from endless scroll page load
var p = loadedContent.find('#navigation li a.arrow').slice(1,2).text().match(/(\d+)P/);
if(p && parseInt(p[1]) != NaN) {
unsafeWindow.gafSetPoints(p[1]);
}
// new page refresh
if(unsafeWindow.gafLoadingNew) {
var codebase = {};
var celms = $('.ajax_gifts>div.post').slice(0,15);
var code = celms.first().find('.title a').attr('href').match(/way\/([a-z0-9]{4,6})\//i)[1];
var i = 0;
for(; i < 10; i++) {
if($(elms[i]).find('.title a').attr('href').match(/way\/([a-z0-9]{4,6})\//i)[1] == code) break;
}
if(i > 0) {
$('div.pagination:first').after(elms.slice(0,i).hide().css({padding:unsafeWindow.gafPadding+'px 0'}));
unsafeWindow.gafAddIgnoreButton(elms.slice(0,i));
unsafeWindow.gafApplyFilter(elms.slice(0,i));
}
celms.each(function(k,v) {
codebase[ $(v).find('.title a').attr('href').match(/way\/([a-z0-9]{4,6})\//i)[1] ] = k;
});
elms.slice(i,20).each(function(k,v) {
var test = codebase[ $(v).find('.title a').attr('href').match(/way\/([a-z0-9]{4,6})\//i)[1] ];
if(test != undefined) {
$(celms[test]).find('.time_remaining').html('').append($(v).find('.time_remaining').html());
$(celms[test]).find('.entries span').slice(0,2).remove();
$(celms[test]).find('.entries').prepend($(v).find('.entries span').slice(0,2));
}
});
unsafeWindow.gafLoadingNew = false;
}
else {
unsafeWindow.gafAddIgnoreButton(elms);
if(elms.length > 0)
{
if($('div.post').length > 0) { $('div.post').last().after(elms); }
else { $('div.pagination:first').after(elms); }
}
$('div.post').css({padding: $('#gafSlider').slider("value") + "px 0"});
unsafeWindow.gafApplyFilter(elms.hide());
}
unsafeWindow.gafAddOverlay();
}
if( (!unsafeWindow.gafReverse && unsafeWindow.gafPage == unsafeWindow.gafMaxPage)
|| (unsafeWindow.gafReverse && unsafeWindow.gafPage == 1) ) {
$('#gafLoading').html("<p>You've reached the end.</p>");
if(unsafeWindow.gafShowSettings && $('.post').length == 0) {
$('#gafLoading').html("<p>There seem to be no giveaways matching your settings.</p>");
}
}
unsafeWindow.gafLoading = false;
unsafeWindow.gafLoadingCheck();
}
// function runs when gafLoading is in veiw
unsafeWindow.gafLoadNextPage = function() {
if(!unsafeWindow.gafLoading
&& ( (!unsafeWindow.gafReverse && unsafeWindow.gafPage < unsafeWindow.gafMaxPage)
|| (unsafeWindow.gafReverse && unsafeWindow.gafPage > 1) )){
unsafeWindow.gafLoading = true;
unsafeWindow.gafPage += (unsafeWindow.gafReverse) ? -1 : 1;
var url = '';
if(window.location.href.match(/forum/)) {
if(unsafeWindow.gafHrefPart.length > 5) {
if(unsafeWindow.gafReverse) {
url = window.location.href.replace(/\d+$/,unsafeWindow.gafPage);
}
else {
url = window.location.href + '/page/' + unsafeWindow.gafPage;
}
}
else {
url = 'http://www.steamgifts.com/forum/page/' + unsafeWindow.gafPage;
}
}
else if(window.location.href.match(/new$/)) {
url = 'http://www.steamgifts.com/new/page/' + unsafeWindow.gafPage;
}
else {
url = 'http://www.steamgifts.com/open/page/' + unsafeWindow.gafPage;
}
$.get(url, function(data) {
unsafeWindow.gafPageLoaded(data);
});
}
}
// credit for code goes to creators to the reddit enchancement suit
// check if obj in the view
unsafeWindow.gafElementInSight = function(obj) {
var top = obj.offsetTop;
var left = obj.offsetLeft;
var width = obj.offsetWidth / 4;
var height = obj.offsetHeight / 4;
while(obj.offsetParent) {
obj = obj.offsetParent;
top += obj.offsetTop;
left += obj.offsetLeft;
}
return top >= window.pageYOffset &&
left >= window.pageXOffset &&
(top + height) <= (window.pageYOffset + window.innerHeight) &&
(left + width) <= (window.pageXOffset + window.innerWidth);
}
// creates a filter array using the sync games
unsafeWindow.gafSync = function() {
// get list from the sync page
$.get('http://www.steamgifts.com/sync', function(data) {
// update the syncfilter array
$(data.match(/\"code\">(.*?)<\//g)).each(function(k,v) {
unsafeWindow.gafSyncFilter.push(v.replace(/\"code\">/g,'').replace(/<\//g,''));
});
unsafeWindow.gafSyncFilter = $.grep(unsafeWindow.gafSyncFilter, function(a) { return !a.match(/^<a /) });
unsafeWindow.gafLoadDLC();
// filter out giveaways using the new list
unsafeWindow.gafApplyFilter($('.ajax_gifts>.post'));
// check if we got the loading element in sight
unsafeWindow.gafLoadingCheck();
});
}
// check if gafLoading is in sight
unsafeWindow.gafLoadingCheck = function() {
if(unsafeWindow.gafElementInSight( document.getElementById('gafLoading') ) ) { // || unsafeWindow.gafPage < 3) {
setTimeout(unsafeWindow.gafLoadNextPage, 1);
}
}
// refresh if on /new page
unsafeWindow.gafRefreshCheck = function() {
if(!unsafeWindow.gafLoading) {
unsafeWindow.gafLoading = true;
unsafeWindow.gafLoadingNew = true;
$.get('http://www.steamgifts.com/new/page/1', function(data) {
unsafeWindow.gafPageLoaded(data);
});
}
setTimeout(unsafeWindow.gafRefreshCheck, 1000 * 90);
}
// toggle endless scroll on various pages
unsafeWindow.gafToggleScroll = function(obj) {
if(obj.innerHTML == "on") {
obj.innerHTML = 'off';
if(window.location.href.match(/\/forum/)) {
if(unsafeWindow.gafHrefPart.length > 5) { unsafeWindow.gafOptions = unsafeWindow.gafOptions.replace(/D/g,''); }
else { unsafeWindow.gafOptions = unsafeWindow.gafOptions.replace(/F/g,''); }
}
else { unsafeWindow.gafOptions = unsafeWindow.gafOptions.replace(/G/g,''); }
}
else {
obj.innerHTML = 'on';
if(window.location.href.match(/\/forum/)) {
if(unsafeWindow.gafHrefPart.length > 5) { unsafeWindow.gafOptions += 'D'; }
else { unsafeWindow.gafOptions += 'F'; }
}
else { unsafeWindow.gafOptions += 'G'; }
}
document.cookie = "gafOptions=" + unsafeWindow.gafOptions + "; expires=Fri, 27 Jul 2030 02:47:11 UTC; path=/";
if(!window.location.href.match(/page\/31337$/)
&& window.location.href.match(/page\/\d+$/)
&& !unsafeWindow.gafReverse ) {
window.location.href = window.location.href.replace(/\/page\/\d+/,'');
}
else {
if(obj.innerHTML == 'on' && unsafeWindow.gafReverse) {
window.location.href = window.location.href.replace(/\/page\/\d+/,'') + '/page/31337';
}
else {
window.location.href = window.location.href;
}
}
}
// toggle reverse order
unsafeWindow.gafToggleRev = function(obj) {
if(obj.innerHTML.match(/newest/)) {
obj.innerHTML = 'oldest first';
unsafeWindow.gafOptions = unsafeWindow.gafOptions.replace(/R/g,'');
unsafeWindow.gafReverse = false;
}
else {
obj.innerHTML = 'newest first';
unsafeWindow.gafOptions += 'R';
unsafeWindow.gafReverse = true;
}
document.cookie = "gafOptions=" + unsafeWindow.gafOptions + "; expires=Fri, 27 Jul 2030 02:47:11 UTC; path=/";
if(unsafeWindow.gafScrollOn && unsafeWindow.gafReverse) {
window.location.href = window.location.href.replace(/\/page\/\d+/,'');
}
else if(unsafeWindow.gafScrollOn) {
window.location.href = window.location.href + '/page/31337';
}
else {
$('.parent_container').reverse().appendTo('.comment_container');
}
}
unsafeWindow.gafHideFeatured = function(obj) {
if(unsafeWindow.gafFeaturedHidden) {
unsafeWindow.gafOptions = unsafeWindow.gafOptions.replace(/Z/g,'');
$(this).attr('checked',false);
unsafeWindow.gafFeaturedHidden = false;
$('.featured').slideDown();
} else {
unsafeWindow.gafOptions += "Z";
$(this).attr('checked',true);
unsafeWindow.gafFeaturedHidden = true;
$('.featured').slideUp();
}
document.cookie = "gafOptions=" + unsafeWindow.gafOptions + "; expires=Fri, 27 Jul 2030 02:47:11 UTC; path=/";
}
unsafeWindow.gafSyncToggle = function(obj) {
if(unsafeWindow.gafSyncState) {
unsafeWindow.gafOptions = unsafeWindow.gafOptions.replace(/S/g,'');
$(this).attr('checked',false);
unsafeWindow.gafSyncState = false;
} else {
unsafeWindow.gafOptions += "S";
$(this).attr('checked',true);
unsafeWindow.gafSyncState = true;
if(unsafeWindow.gafSyncFilter.length < 1) unsafeWindow.gafSync();
}
document.cookie = "gafOptions=" + unsafeWindow.gafOptions + "; expires=Fri, 27 Jul 2030 02:47:11 UTC; path=/";
}
// rearrange page to fit in 500px window
unsafeWindow.gafOverlayLoaded = function(obj) {
$('#gafPopupBackground').fadeIn('slow');
var e = $(obj).contents();
// update points from the overlay page
var p = e.find('#navigation li a.arrow').slice(1,2).text().match(/(\d+)P/);
if(p && parseInt(p[1]) != NaN) {
unsafeWindow.gafSetPoints(p[1]);
}
if( e.find('#form_enter_giveaway a.entered').length > 0 ) { $('.ajax_gifts>div.post.quickview').addClass('fade'); }
else { $('.ajax_gifts>div.post.quickview').removeClass('fade'); }
e.find('.footer,.featured .left').remove();
e.find('.bg_gradient .content').first().remove();
e.find('.content').css({width:'500px'});
e.find('.bg_gradient').css({'background-position':'center center'});
e.find('.body_container').css({width:'400px'});
e.find('.parent_container').css({padding:0}).find('.comment.parent').css({padding:'5px'});
e.find('.featured').css({padding:0}).find('.right').css({'padding-top':'5px'});
e.find('body').css({'min-width':0,width:'510px'});
e.find('#comment_form').prependTo(e.find('.wrapper').css({padding:0})).find('.body_container').attr('style','')
var env = $('#gafOverlay iframe').contents().find('#comment_form');
$('<input type="submit" value="Comment and Enter" />')
.appendTo(env.find('.comment_reply')).click(function() {
$.post($('#gafOverlay iframe').attr('src'),
$('#gafOverlay iframe').contents().find('#form_enter_giveaway').serialize(),
function(data) {
env.find('form')
.append('<input type="hidden" name="submit_comment" value="1" />').submit();
});
return false;
});
env.find('.comment_reply input:first').attr("value","Submit");
if(!$(obj).hasClass('gafMoved')) {
$(obj).addClass('gafMoved');
var x = $(obj).parent().css('left').match(/(\d+)/)[1];
var y = $(obj).parent().css('top').match(/(\d+)/)[1];
$(obj).parent().css({left: (x - 530) + "px",top:y - 100});
$(obj).css({width:'530px',height:'400px'}).parent().find('img').hide();
}
}
unsafeWindow.gafAddOverlay = function() {
$('.post .right').each(function(k,v) {
v = $(v);
if(v.find('div').length > 0) return;
v.find('img').css({float:'right'})
$('<div>Quick View</div>').css({opacity:0,'font-size':'20px',color:"#000",'font-size':'25px','background-color':'#ccc',float:'left',position:'absolute',width:'144',height:'29px','padding':'20px','font-weight':'bold',cursor:'pointer','text-align':'center'})
.mouseleave(function() { $(this).stop(true,true).animate({opacity:'0'},1000); })
.mouseover(function() { $(this).stop(true,true).animate({opacity:'0.75'},100); })
.appendTo(v)
.click(function() {
if($('#gafOverlay').length > 0) return false;
$(this).parent().parent().addClass("quickview");
$('body').append("<div style='z-index:25;position:absolute;box-shadow:0 0 3px #000;padding:4px;background-color:#F9F9FB;border-radius:5px' id='gafOverlay'><iframe style='width:1px;height:1px;border:0' onload='javascript:gafOverlayLoaded(this);' src='"+$(this).parent().find('a').attr('href')+"'></iframe><img src='data:image/gif;base64,R0lGOD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
left: (elm.offsetLeft - 20) + 'px'
});
return false;
});
});
}
unsafeWindow.gafPutLoading = function() {
$('.pagination:last').html("<div id='gafLoading' style='text-align: center;'><img src='data:image/gif;base64,R0lGODlhIAAgAPMAAP///wAAAMbGxoSEhLa2tpqamjY2NlZWVtjY2OTk5Ly8vB4eHgQEBAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADdEAAAh+QQJCgAAACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY/CZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB+A4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6+Ho7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq+B6QDtuetcaBPnW6+O7wDHpIiK9SaVK5GgV543tzjgGcghAgAh+QQJCgAAACwAAAAAIAAgAAAE7hDISSkxpOrN5zFHNWRdhSiVoVLHspRUMoyUakyEe8PTPCATW9A14E0UvuAKMNAZKYUZCiBMuBakSQKG8G2FzUWox2AUtAQFcBKlVQoLgQReZhQlCIJesQXI5B0CBnUMOxMCenoCfTCEWBsJCol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b0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA==' /><p>Gremlins are fetching more stuff. Please standby...</p></div>");
}
unsafeWindow.gafSetPoints = function(pts) {
var e = $('#navigation li a.arrow:contains("Account")');
var a = e.text().match(/(\d+)P/);
if(a.length)
{
var p = a[1];
var y = Math.round(Math.random()*60)-50;
var x = Math.round(Math.random()*40)-20;
var total = pts - p;
$('#nav,#navigation').each(function(k,v) {
v = $(v).find('li a.arrow:contains("Account")').text('Account ('+pts+'P)');
});
if(total == 0) return;
$('<div>'+((total >= 0)?'+'+String(total):total)+'</div>')
.appendTo('body')
.css({position:'fixed',
top:'0px',
left: ($('#navigation li a.arrow:contains("Account")')[0].offsetLeft + 50) + "px",
'font-size':'20px',
'font-weight':'bold',
'text-shadow':'#666 0px 0px 6px',
color:(total >= 0) ? '#77FF73' : 'red',
'z-index':55 })
.show().animate({top:60+x,left:'+='+y},350)
.delay(300).animate({fontSize:'60px',top:'-=10',left:'-=20'},100)
.delay(100).fadeOut(300,function(){ $(this).remove(); });
}
}
unsafeWindow.gafDLCSyncd = [];
unsafeWindow.gafLoadDLC = function() {
// make sure DLC database is loaded
if(typeof unsafeWindow.gafDLC === 'undefined') {
setTimeout(unsafeWindow.gafLoadDLC, 100);
return;
}
// add all
for(var item in unsafeWindow.gafDLC) {
if($.inArray(item, unsafeWindow.gafSyncFilter) == -1) $.merge(unsafeWindow.gafDLCSyncd, unsafeWindow.gafDLC[item]);
};
}
unsafeWindow.gafUpdateViews = function() {
var v = ['All', 'Filtered', 'Wishlist','Entered', 'Limit by points','DLC','Regular','Group','C.Green','C.Red'];
// load filter layout
var s = '';
for(var i = 0; i < v.length; i++)
s += (unsafeWindow.gafFilOpts >> i) % 2;
// place container
if($('#gafViewLinks').length == 0) {
$('body').prepend("<style>#gafFNav {float:right;}#gafFNav ol{list-style-type:none;float:left;}#gafFNav ol>li{float:left;height:25px; background-color: #fff; border: 1px solid #ddd; border-radius:10px 10px 10px 10px;}#gafFNav ol>li:hover{background-color: #347DB5;border: 1px solid #347DB5;}#gafFNav ol>li>a.arrow{background-image: url(../img/navigation_dropdown_arrow_click.png);background-repeat: no-repeat;background-position:right center;color: #347DB5; padding-right:34px;}#gafFNav ol>li:hover>a.arrow{background-image: url(../img/navigation_dropdown_arrow_hover.png);}#gafFNav ol>li.open>a.arrow{background-image: url(../img/navigation_dropdown_arrow_click.png);}#gafFNav ol>li.open{background-color:#fff;border: 0px;border-radius:5px 5px 0 0;}#gafFNav ol>li>a{font-weight:bold;padding:5px 12px;text-decoration:none;display:block;font-size:11px;color:#c3dbed;}#gafFNav ol>li.open>a{padding-top:7px;}#gafFNav ol>li:hover>a{color:#fff;}#gafFNav ol>li.open>a{color:#434343;}#gafFNav .relative-dropdown{float:left;position:relative;}#gafFNav .absolute-dropdown{overflow:hidden;z-index:19;top:25px;right:-112px; position:absolute; width:400px;padding:5px;background-color:#fff;border-radius:5px 0px 5px 5px;display:none;box-shadow:5px 5px 4px rgba(0, 0, 0, 0.1), 3px 3px 2px rgba(0, 0, 0, 0.1), 2px 2px 1px rgba(0, 0, 0, 0.1);}#gafFNav .absolute-dropdown ul{list-style-type:none;}#gafFNav .absolute-dropdown ul>li{padding-top:5px;padding-bottom:5px}#gafFNav hr{float:left;margin-top:7px;border-top:1px dashed #c6c6c6;border-bottom:1px dashed #fff;border-left:none;border-right:none;}#gafFNav .hr{float:left;color:#347DB5;font-weight:bold;}#gafViewLinks .price.min{padding-right:5px}#gafViewLinks .price.max{padding-left:5px}#gafViewLinks .price{width: 40px;color:#89B363;font-weight:bold;text-align:center;float:left}#sg_fdlc_range{float:left}</style>");
$('.pagination:first').prepend('<div id="gafFNav"><ol><li><div class="relative-dropdown"><div class="absolute-dropdown"><ul id="gafViewLinks"></ul></div></div><a href="" class="arrow">Modify filter</a></li></ol></div>');
}
$("#gafFNav, #gafFNav .absolute-dropdown.open").mouseout(function() {
var e = $(this);
unsafeWindow.gafFNav_n = setTimeout(function() {
e.find('.open').removeClass('open').find('.absolute-dropdown').hide();
}, 1000);
});
$("#gafFNav, #gafFNav .absolute-dropdown.open").mouseover(function() {
if(typeof unsafeWindow.gafFNav_n !== 'undefined') clearTimeout(unsafeWindow.gafFNav_n);
});
var elm = $('#gafViewLinks');
elm.html('<li></li><li></li><li><hr style="margin-right:5px;margin-left:-5px;width:20px;"/><span class="hr">Contributor range</span><hr style="margin-left:5px;width:100%;float:none;"/><div class="clear_both"></div></li><li><div class="price min">0$</div><div id="sg_fdlc_range" style="width:300px"></div><div class="price max">4000$</div><div class="clear_both"></div></li>');
elm = elm.find('li:first');
// fill the container with the options
for(var i = 0; i < v.length; i++) {
if(i > 4) elm = elm.parent().find('li').slice(1,2);
elm.append("<input type='checkbox' id='sg_fid"+i+"' " + ((parseInt(s[i])==1)?'checked':'') + "/> "
+ ((i>=6)?"<a href='#' id='sg_link"+i+"'>":'') + v[i] + ((i>=5)?"</a>":'') + ' ');
}
// if all is checked, disable the rest of the options
if(s[0]==1) $('#gafViewLinks input[type="checkbox"]').slice(1,99).attr('disabled','disabled');
$('#sg_fdlc_range').slider({
range:true,values:[0,1000],min:0,step:1,max:200,animate:true,
slide: function(event, ui) {
var e = $('#sg_fdlc_range').parent().find('.price');
e.first().text(Math.floor(ui.values[0]*(ui.values[0]/10)) + '$');
e.last().text(Math.floor(ui.values[1]*(ui.values[1]/10)) + '$');
},
stop: function(event, ui) {
unsafeWindow.gafApplyFilter($('.ajax_gifts>div.post'));
setTimeout(unsafeWindow.gafLoadingCheck, 1000);
}
});
}
$("#gafLivePreview h1:first").live("click", function() {
var e = $("#gafLivePreview .markdown");
if(e.is(':visible')) e.hide();
else e.show();
});
$("#create_form textarea#body, #comment_form textarea#body, .user_edit textarea").live('keyup', function() {
var e = $(this);
if($("#gafLivePreview").length > 0 && e.parent().parent().find("#gafLivePreview").length == 0) $("#gafLivePreview").remove();
if(e.val() != "" && $("#gafLivePreview").length == 0) {
var insertAfterElement;
if(window.location.href.match(/forum\/(new|edit)$/)) insertAfterElement = e.parent().find('.clear_both');
else {
insertAfterElement = e.parent().parent().find('.clear_both');
if(insertAfterElement.length == 0)
insertAfterElement = e.parent().parent().parent().parent().find('.clear_both');
if(insertAfterElement.length == 0)
insertAfterElement = e.parent().parent().parent().parent().find('.user_edit');
}
insertAfterElement.after('<div id="gafLivePreview" style="width:700px"><h1 style="cursor:pointer;color: #347DB5; border: solid 1px #ddd;border-radius: 4px 4px 0px 0px; font-size: 14px; padding: 5px;background-color: #F4F4F4;">Live Preview</h1><div class="markdown comment_container" style="background-color: #fff;border: solid 1px #ddd; border-top: 0px; padding: 5px;"></div></div>');
} else if(e.val() == "") {
$('#gafLivePreview').remove();
return;
}
var tmp = e.val();
// emulate markdown
// remove long vertical spaces
tmp = tmp.replace(/\n{3,}/g,"\n\n");
// add horizontal spaces
tmp = tmp.replace(/\-{3,}/gi,"<hr />");
// headings
tmp = tmp.replace(/(<\/?p>|\n|^)(\#{1,3}) (.*?)\n/gi, function(a,b,c,d) {
var str = (b == "<p>") ? "" : "</p>";
var n = c.length;
return str + "<h"+n+">" + d + "</h"+n+"><p>";
});
tmp = tmp.replace(/\n?(.*?)\n\={4,}/gi,"</p><h1>$1</h1><p>");
tmp = tmp.replace(/\n?(.*?)\n\-{4,}/gi,"</p><h2>$1</h2><p>");
// break line and paragraph
tmp = tmp.replace(/( \n)/gi,"<br />");
tmp = tmp.replace(/(\n\n)/gi,"</p><p>");
// handle urls
tmp = tmp.replace(/\[(.*?)\]\((((http)s?\:\/\/)?.*?)\)/gi, function(a,b,c,d,e) {
return '<a href="'+((e=='http')?'':'http://')+c+'">'+b+'</a>' });
// bullets points, very basic
tmp = tmp.replace(/\n\* /gi,"<br /> ● ");
tmp = tmp.replace(/>\* /gi,"> ● ");
// italics and bold
tmp = tmp.replace(/(\*\*|__)(.*?)\1/gi,"<strong>$2</strong>");
tmp = tmp.replace(/\*(.*?)\*/gi,"<em>$1</em>");
// code tag
tmp = tmp.replace(/`(.*?)`/gi,"<code>$1</code>");
// fix paragraphs
tmp = "<p>"+tmp+"</p>";
tmp = tmp.replace(/<p><\/p>/g,"");
$("#gafLivePreview .markdown").html(tmp);
});
// move the comment box at the top for less frustration
if(window.location.href.match(/\/forum\//)) $('.discussions').after($('#comment_form'));
else $('.sub_navigation').before($('#comment_form'));
$("span.cancel a").live('mousedown', function() {
$("#gafLivePreview").remove();
setTimeout(function() {
if(window.location.href.match(/\/forum\//)) $('.discussions').after($('#comment_form'));
else $('.sub_navigation').before($('#comment_form'));
}, 120);
});
$("a.cancel_edit_comment").live('mousedown', function() {
$("#gafLivePreview").remove();
});
unsafeWindow.gafAddHC = function(elm) {
$(elm).find(".comment_container .parent_container .border_container").parent().find(".parent .reply_link").parent().append(' or <a href="#" class="gafHideChild show">Hide child comments</a>');
}
unsafeWindow.gafAddHC('body');
$(".gafHideChild").live("click", function() {
var e = $(this);
if(e.hasClass("show")) {
e.removeClass("show");
e.text("Show child comments");
e.parent().parent().parent().parent().parent().find(".border_container").stop(true,true).slideUp('fast');
} else {
e.addClass("show");
e.text("Hide child comments");
e.parent().parent().parent().parent().parent().find(".border_container").stop(true,true).slideDown('fast');
}
return false;
});
// main code
if(window.location.href.match(/forum\/edit$/)) return; // rest of the code is not applicable on this page
unsafeWindow.gafFilter = [];
unsafeWindow.gafSyncFilter = [];
// flags for options
// G - giveaway endless scroll turned on
// F - forum endless scroll turned on
// D - dicussion endless scroll
// R - reverse order of comments
// S - ignore sync games
unsafeWindow.gafOptions = "GFDR";
unsafeWindow.gafPadding = 25;
unsafeWindow.gafFilOpts = 230;
var $ = unsafeWindow.jQuery;
$.fn.reverse = [].reverse;
// add popup elements
$('body').append("<div id='gafPopupBackground' style='position:fixed;display:none;top:0;left:0;height:100%;width:100%;background:#000000;z-index:20;opacity: 0.4;' onClick='javascript: gafPopupHide();'></div><div id='gafPopup' style='position:fixed;float:left;left:50%;top:50%;background:#FFFFFF;display:none;border:1px solid #cccccc;z-index:21;padding:8px;height:295px;width:408px;border-radius: 10px 10px 10px 10px;box-shadow: 0 0 20px #000000;'><h1 style='color: #347DB5;font-size: 22px;'>Giveaway Filter</h1><p style='color: #4F565A;font-size: 12px;'>Enter the games you want filtered out from the giveaway list separated by commas. (eg 'Portal 2, Half-Life 2') <b>/Save by clicking on the background/</b></p><textarea id='gafFilterInput' style='width:400px;height:200px;' onchange='javascript:gafFormUpdate();'></textarea><p style='color: #4F565A;font-size: 12px;'><input type='checkbox' value='tiny gremlin' id='gafSyncCBox' onchange='javascript:gafSyncToggle();'> Ignore games in my sync library. (Update sync page <a href='http://www.steamgifts.com/sync'>here</a>)</p><p style='color: #4F565A;font-size: 12px;'><input type='checkbox' value='medium gremlin' id='gafHideFeatCBox' onchange='javascript:gafHideFeatured();'> Check this box if you want to hide featured giveaway.</p></div>");
// read cookie
var i,j,val='',c=document.cookie.split(";");
for (i=0;i<c.length;i++) {
var testStr = $.trim(c[i].substr(0,c[i].indexOf("=")));
if(testStr == "gafOptions") {
unsafeWindow.gafOptions = c[i].substr(c[i].indexOf("=")+1);
}
else if (testStr == "gafPadding") {
unsafeWindow.gafPadding = c[i].substr(c[i].indexOf("=")+1);
}
else if (testStr == "gafFopts") {
unsafeWindow.gafFilOpts = c[i].substr(c[i].indexOf("=")+1);
}
}
if(unsafeWindow.localStorage.gafFilter) {
$('#gafFilterInput').text(unsafeWindow.localStorage.gafFilter)
unsafeWindow.gafFilter = unsafeWindow.localStorage.gafFilter.split(",");
}
unsafeWindow.gafLoading = false;
unsafeWindow.gafLoadingNew = false;
unsafeWindow.gafPage = 1;
unsafeWindow.gafMaxPage = 1;
unsafeWindow.gafPerPage = 50;
unsafeWindow.gafFloatMenuOn = false;
unsafeWindow.gafScrollOn = true;
unsafeWindow.gafShowESS = true;
unsafeWindow.gafReverse = false;
unsafeWindow.gafShowSettings = true;
unsafeWindow.gafShowReverse = false;
unsafeWindow.gafRepReverse = false;
unsafeWindow.gafSyncState = false;
unsafeWindow.gafFeaturedHidden = false;
unsafeWindow.gafHrefPart = window.location.href.split('/');
switch(unsafeWindow.gafHrefPart[3]) {
case "forum":
if(unsafeWindow.gafHrefPart[4] == "replies"){
unsafeWindow.gafScrollOn = false;
unsafeWindow.gafShowSettings = false;
unsafeWindow.gafShowESS = false;
break;
}
if(unsafeWindow.gafHrefPart.length > 5) {
if( unsafeWindow.gafOptions.match('R')
&& !window.location.href.match(/page\/31337$/))
{
window.location.href = window.location.href.split('/').slice(0,6).join('/') + '/page/31337';
}
if( unsafeWindow.gafOptions.match('R')
|| window.location.href.match(/page\/31337$/)) { unsafeWindow.gafReverse = true; }
if( !unsafeWindow.gafOptions.match('D') ) { unsafeWindow.gafScrollOn = false; }
unsafeWindow.gafPerPage = 40;
unsafeWindow.gafShowReverse = true;
}
else {
if( !unsafeWindow.gafOptions.match('F') ) { unsafeWindow.gafScrollOn = false; }
if( unsafeWindow.gafOptions.match('R') ) { unsafeWindow.gafRepReverse = true; }
unsafeWindow.gafPerPage = 50;
}
unsafeWindow.gafShowSettings = false;
break;
case "new":
setTimeout(unsafeWindow.gafRefreshCheck, 1000 * 60);
case "":
case "open":
if( !unsafeWindow.gafOptions.match('G') ) { unsafeWindow.gafScrollOn = false; }
unsafeWindow.gafReverse = false;
if( unsafeWindow.gafOptions.match('S') ) {
unsafeWindow.gafSync();
}
break;
}
if( unsafeWindow.gafOptions.match('S') ) {
unsafeWindow.gafSyncState = true;
$('#gafSyncCBox').attr('checked',true);
}