-
Notifications
You must be signed in to change notification settings - Fork 1
/
giveawayKiller.user.js
491 lines (458 loc) · 21 KB
/
giveawayKiller.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
// ==UserScript==
// @name Giveaway Killer
// @namespace https://github.com/gekkedev/GiveawayKiller
// @version 1.1.7
// @description Semi-automatic tool for Steam-related giveaway websites
// @author gekkedev
// @match *://*.marvelousga.com/*
// @match *://*.dupedornot.com/*
// @match *://*.indiegala.com/*
// @match *://*.dogebundle.com/*
// @match *://*.giveaway.su/*
// @match *://*.steamgifts.com/*
// @match *://*.simplo.gg/*
// @match *://*.giveawayhopper.com/*
// @match *://*.cubicbundle.com/*
// @match *://*.treasuregiveaways.com/*
// @match *://*.goldengiveaways.org/*
// @match *://*.bananagiveaway.com/*
// @match *://*.grabfreegame.com/*
// @match *://*.gamingimpact.com/*
// @match *://*.gamehag.com/*
// @match *://*.gamecode.win/*
// @match *://*.gleam.io/*
// @match *://*.steamcommunity.com/openid/login*
// @match *://*.steamcommunity.com/oauth/login*
// @match *://*.steamcommunity.com/groups/*
// @grant GM.getValue
// @grant GM.setValue
// @updateURL https://raw.githubusercontent.com/gekkedev/GiveawayKiller/master/giveawayKiller.user.js
// @downloadURL https://raw.githubusercontent.com/gekkedev/GiveawayKiller/master/giveawayKiller.user.js
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.10.0/js/md5.min.js
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @require https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.min.js
// @require https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js
// @run-at document-end
// ==/UserScript==
(async () => {
J = jQuery.noConflict(true); //to prevent i.e. broken buttons when a site uses jquery too
J.extend(J.expr[':'], { //https://stackoverflow.com/a/4936066
'containsi': function(elem, i, match, array)
{
return (elem.textContent || elem.innerText || '').toLowerCase()
.indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
killerNotice = function(message, type = "info") { //types: success/info/warn/error
console.log(message);
J.notify("GiveawayKiller v" + GM_info.script.version + ": " + message, {
autoHideDelay: 10000,
className: type
});
};
/* Configuration
* Determine what to do for this page based on what's defined in the "config" variable
*
* hostname: String
* The hostname of the site we're setting the config for. Must be the same as what's defined
* as @match in the metadata block above.
*
* ads: Boolean
* This tells us if the site we visit has ads (this refers to banners of any size, mostly from Google). We'll then trigger the removal function for that.
*
* autologin: String
* This is a selector for a link which has to be visited in order to get forwarded to the login page.
*
* trigger: Array of Functions
* Triggers may or may not be site specific; they are usually for task solving and can be reused on unmodified instances of poorly programmed website scripts.
*
* clickables: Array of String
* These are CSS Selectors which will be buttons to be clicked (in ascending order). Some may not be clickable but each click that doesn't need to be done is already a success.
*/
var removePopups = function(){
//killerNotice("removing popups!");
removeElement("a[id^='popup']");
//does not work on all sites, a workaround is in the next paragraph
J(document).ready(function(){
J("html").unbind("click");
});
//necessary for gamecode.win and dupedornot.com
var d = new Date();
var todayStr = (d.getUTCMonth() + 1) + "/" + d.getUTCDate() + "/" + d.getUTCFullYear();
document.cookie = "haveVisited1=" + todayStr + "; path=/";
//setTimeout(removePopups, 1000);
};
var fakeClickLinks = function() {
J("form[action*='verify_click.php']").trigger("submit");
};
var solveGamehagUsernameCheck = function() {
//"Kruemel" //some random user, just pick another one from the ranklist in case they block this user ;-)
};
scanForElement = function(identifiers) { //iterates through elements and returns true if all elements exist at least once
//console.log("found " + ident + " " + jQuery(ident).length + " time(s)");console.log(jQuery(ident));
if (typeof identifiers != "object") identifiers = [identifiers]; //wrap it as array in case it isn't one
counter = Object.keys(identifiers).length;
J.each(identifiers, function(i, ident) {
if (J(ident).length >= 1) {
counter--;
} else {
console.log('cannot find ' + ident);
}
});
return counter == 0;
};
hideElement = function(ident) {
if (scanForElement(ident)) {
J(ident).hide();
}
};
removeElement = function(ident) {
J(ident).remove();
};
var visitLink = function(ident){
window.location.replace(J(ident).attr("href"));
};
var removeGoogleAds = function(){
if (scanForElement("ins[class*='adsbygoogle']")) {
killerNotice("Google ads found, removing now!");
removeElement("ins[class*='adsbygoogle']");
setTimeout(removeGoogleAds, 1000);
}
};
var getEncapsedString = function(input, delimiter) {//just gets the first occurrence
var startpos = input.indexOf(delimiter) + delimiter.length;
var endpos = input.indexOf(delimiter, startpos);
return input.substring(startpos, endpos);
};
var getRandomInt = function(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
//stackoverflow.com/a/1314389
var checkGetParameter = function(parameterName) {
var url = window.location.href;
if(url.indexOf('?' + parameterName) != -1)
return true;
else if(url.indexOf('&' + parameterName) != -1)
return true;
return false
}
//stackoverflow.com/a/5448595
var returnGetParameter = function(parameterName) {
var result = null,
tmp = [];
location.search
.substr(1)
.split("&")
.forEach(function (item) {
tmp = item.split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
});
return result;
};
/*var autoJoinGroups = function() {
//giveaway.su
var groups = $("button[data-type='steam.group']");
for (var i = 0; i < groups.length; i++) {
var group = groups[i];
$.get("https://steamcommunity.com/profiles/"+$("aside[data-steam-id]").data("steam-id")+"/groups/").always(function(jqXHR) {
var regexp = new RegExp("href=\"javascript:leaveGroupPrompt\\('"+$(group).data("check")+"',", "g");
if (jqXHR && regexp.test(jqXHR))
toggleActionButton(button);
else
$(button).prop("disabled", false).find(".glyphicon.spin").removeClass("spin");
});
group.remove();
}
};*/
var taskSkipper_1 = function() {//giveaway.su/varlick
if (J("article .extension").length) {
J("article .extension").addClass("installed");
var timestamp = J("article .extension").data("timestamp");
var csrf = J("article .extension").data("csrf");
var extension = md5(timestamp+""+csrf);
var secret = J("article .extension").data("secret");
J.get(window.location.pathname+"?extension="+extension+"×tamp="+timestamp+"&csrf="+csrf+(secret ? "&secret="+secret : ""), function(response) {
J("article").replaceWith(response);
//this is the extension version and should not depend on manual updates
J("article").attr("extension-version", "chrome-3.4.9");//+chrome.runtime.getManifest().version);
var button = J("#getKey a");
var actions = 0;
J("#actions [data-action-id]").each(function(i,el){
actions += parseInt(J(el).data("action-id"));
if (J(el).find("button[data-type='steam.curator']").length) {
J(el).fadeOut();
} else if (J(el).find("button[data-type='youtube.subscribe']").length) {
J(el).fadeOut();
} else if (J(el).find("button[data-type='twitter.follow']").length) {
J(el).fadeOut();
} else if (J(el).find("button[data-type='steam.game.wishlist']").length) {
J(el).fadeOut();
} else if (J(el).find("td:contains('Invite')").length) {
J(el).fadeOut();
}
});
J(button).attr("href", J(button).attr("href")+"&actions="+md5(actions)).removeClass("disabled");
J("#getKey").prepend("Giveaway Killer by gekkedev has skipped some tasks for you, because this site is trying to manipulate the Steam store and to get access over your private data. Key claiming does usually work when you have joined all the required groups. Please use the Giveaway Helper by Citrinate in order to join groups easier. Linking accounts happens at your own risk and is a possible reason of unwanted actions commited via your account (account theft, unwanted purchases, etc.) and is qualifying you for punishments regarding Steam T.O.S. violations.<br>");
});
}
};
var taskSkipper_2 = function() {//goldengiveaways
var tasks = J("a[onclick*='task()']");
if (tasks.length) {
tasks.each(function(counter, element){
J.get(element.href);
});
location.reload();
} else {
J(".giveaway-new").last().prepend("<div class='alert alert-danger'>Giveaway Killer by gekkedev has skipped some tasks for you, because this site is trying to manipulate the Steam store by asking you to follow specific curators. Doing such would qualify you for punishments regarding Steam T.O.S. violations.</div><br>");
}
};
var taskSkipper_3 = function() {//bananagiveaway/bananatic/grabfreegame.com
//we can autosolve only link visiting (including facebook and youtube);
var tasks = J("li:has(span.icon:has(i.banicon.banicon-logo-small)):not(li:containsi('collect'):containsi('banana'))");
tasks = tasks.add(J("li:contains('FB'):containsi('Like'), li:has(span.icon:has(i.banicon.banicon-facebook))"));
tasks = tasks.add(J("li:contains('YT'):containsi('Check'):not(li:containsi('sub'), li:has(span.icon:has(i.banicon.banicon-youtube)):not(li:containsi('sub')"));
//steam group, twitter, and point collection tasks might be different
//tasks = tasks.add(J("li:contains('Share'):contains('Twitter')"));
//sharing on non.proprietary social media platforms
//tasks = tasks.add(J("li:containsi('Share'):not(li:containsi('Twitter')"));
tasks = J.unique(tasks); //filters out any duplicates
tasks = tasks.filter(":not(:containsi('completed'))");
killerNotice(tasks.length + " skippable tasks found.");console.log(tasks);//return true;
//dig deeper, but keep the task steps together
tasks = tasks.find("div[class='buttons']");
var successes = 0;
J.ajaxSetup({async:false}); //not so smooth looking but easy
if (tasks.length) {
tasks.each(function(counter, task){
killerNotice("Solving one task...");
var youtubebutton = J(task).find("button[data-ytid]");
if (youtubebutton.length) { //just hit the second link, since there is just one.
killerNotice("skipping the first link (youtube video)");
J.get(
getEncapsedString(J(J(task).find("button[onclick*='window.location.href']")).attr("onclick"), "'"), //previously: button[disabled]
function(){
successes++;
killerNotice("Solved!");
}
);
} else {
J.get( //hit the first link...
getEncapsedString(J(J(task).find("button[onclick*='window.open']")).attr("onclick"), "'")).always( //previously: button:not([disabled])
function() {
J.get(
getEncapsedString(J(J(task).find("button[onclick*='window.location.href']")).attr("onclick"), "'")).always( //previously: button[disabled]
function() {//always returns 302 so we should do this differently.
successes++;
killerNotice("Solved!");
}
);
}
);
}
});
J.ajaxSetup({async:true});
if (tasks.length == successes) {
location.reload();
} else {
killerNotice("Could not solve all solveable tasks!");
}
} else {
J("div[class='bottom'] span[class='status']").prepend("<div class='alert alert-danger'>Giveaway Killer by gekkedev has skipped some tasks for you, because this site is exploiting it's users by excessive ad banner usage plus making users fullfill specific tasks which generate a dozen times more revenue than what is offered to the user.</div><br>");
}
};
var taskSolver_IG = function() {
/*J.ajax({
url: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js',
datatype: 'script',
cache: true
}).done(function() {
J('#myModal-givform').modal('show');
});*/
J('#myModal-givform').modal('show');
};
var gleamTaskSolver = function() {console.log(J("a.enter-link.custom-border"));
//J("a.enter-link.custom-border") //fillable field, nothing to automate there except opening
links = J("a.enter-link.instagram-border"); //instagram url visiting
links = links.add(J("a.enter-link.youtube-border")); //youtube "subscribing" (url visiting)
links = J.unique(links); //filters out any duplicates
killerNotice(links.length + " skippable tasks found.");
links.each(function(i, task){
killerNotice("Solving one task...");
if (J(task).find("i.fa-check").length == 0) {
task.click();
taskcontainer = J(J(task).parent());
taskcontainer.find("a.btn-large")[0].click();
taskcontainer.find(".form-actions button:containsi('continue')")[0].click();
killerNotice("...solved! <3", "success");
} else {
killerNotice("...already solved! :-)", "warn");
}
});
};
var openIDConfirm = function() { //can be utilized for oauth&openid; :contains('Sign In') might not work due to a multilingual interface
if (scanForElement([".OpenID_loggedInText", "input[type='submit']#imageLogin"]))
J("input[type='submit']#imageLogin").click();
}
//configuration
var config = [
{
hostname: "marvelousga.com",
ads: true,
autologin: "a[href='?login']",
//clickables: ["button[type=submit][name!=sg][id!=submit]"],
//autosolve: "'div.collapse* button'"
trigger: [removePopups, solveGamehagUsernameCheck] //fakeClickLinks
},
{
hostname: "dupedornot.com",
ads: true,
autologin: "a[href*='/auth/steam']",
trigger: [removePopups]
},
{
hostname: "dogebundle.com",
ads: false,
autologin: "a[href*='?page=login']"
},
{
hostname: "indiegala.com",
ads: true,
clickables: ["button#close-socials"],
trigger: [taskSolver_IG]
},
{
hostname: "giveaway.su",
ads: true,
autologin: "a.steam-login",
trigger: [taskSkipper_1],
custom: function() {hideElement("ul.menu");}
},
{
hostname: "simplo.gg",
ads: true,
autologin: "div.steam-button a",
clickables: ["w-div[role=dialog] span"]
},
{
hostname: "steamgifts.com",
ads: true,
autologin: "a.nav__sits"
},
{
hostname: "chubbykeys.com",
ads: false
},
{
hostname: "giveawayhopper.com",
ads: false,
autologin: "a[href='?login']"
},
{
hostname: "cubicbundle.com",
ads: false,
autologin: "a.no-login"
},
{
hostname: "treasuregiveaways.com",
clickables: ["input[onclick*=incr]"],
custom: function() {J('form[action="?login"]').submit();}
},
{
hostname: "goldengiveaways.org",
ads: false,
autologin: "a[href='/?login']",
trigger: [taskSkipper_2]
},
{
hostname: "bananagiveaway.com",
ads: true,
autologin: "a[href*='/steam/']",
trigger: [taskSkipper_3]
},
{
hostname: "grabfreegame.com",
ads: true,
autologin: "a[href*='/steam/']",
trigger: [taskSkipper_3]
},
{
hostname: "gamingimpact.com",
ads: true,
autologin: "a[href*='/steam/']",
trigger: [taskSkipper_3]
},
{
hostname: "gamehag.com",
ads: true
},
{
hostname: "gamecode.win",
ads: true,
//autologin: "a[href*='/login']",
trigger: [removePopups]
},
{
hostname: "gleam.io",
ads: false,
trigger: [gleamTaskSolver]
},
{
hostname: "steamcommunity.com",
ads: false,
trigger: [openIDConfirm]
//custom: function() {if (checkGetParameter("killerjoin")) {if (scanForElement("#join_group_form")) { killerNotice("Joining a Steam group!");J("#join_group_form").submit();}}}
}
];
//execution
for(var i = 0; i < config.length; i++) {
var site = config[i];
if(document.location.hostname.split(".").splice(-2).join(".") == site.hostname) {
killerNotice('Welcome to ' + site.hostname + '!');
if (site.ads) {
removeGoogleAds();
//removePopups();
//add other ad services here if known
}
if (site.autologin !== undefined) {
if (scanForElement(site.autologin)) {
var cooldowntime = 5 * 60; //logging in once every 5 minutes is enough, everything else is wayy too likely a broken authentification system
var nowinseconds = Math.round(Date.now() / 1000);
var lastlogin = await GM.getValue('lastlogin_' + site.hostname, nowinseconds)
if (nowinseconds == lastlogin || nowinseconds >= lastlogin + cooldowntime) {
GM.setValue('lastlogin_' + site.hostname, nowinseconds);
killerNotice('Performing autologin.');
visitLink(site.autologin);
} else {
killerNotice("Logging in too often! We should cool down for at least " + (cooldowntime - (nowinseconds - lastlogin)) + " seconds");
}
}
}
if (site.clickables !== undefined) {
if (site.clickables.length > 0) {
for(var j = 0; j < site.clickables.length; j++) {
if (J.isArray(site.clickables[j])) {//randomization doesn't look like the best solution here. what's it even for?
j = getRandomInt(0, site.clickables[j].length);
}
if (scanForElement(site.clickables[j])) {
killerNotice("Clicking a button for you <3");
J(site.clickables[j]).click();
console.log(j);
}
}
}
}
if (site.trigger !== undefined) {
for(var j = 0; j < site.trigger.length; j++) {
killerNotice('Swinging my magical wand(' + site.trigger[j].name + ')!');
site.trigger[j]();
}
}
if (site.custom !== undefined) {
killerNotice('Doing random magic!');
site.custom();
}
}
}
})();