Skip to content

Instantly share code, notes, and snippets.

@FrozenFrog
Last active July 31, 2016 16:55
Show Gist options
  • Save FrozenFrog/b47a786b1573a86528897c1055c6bbc0 to your computer and use it in GitHub Desktop.
Save FrozenFrog/b47a786b1573a86528897c1055c6bbc0 to your computer and use it in GitHub Desktop.
Tampermonkey script automate get Kaspersky 3 months key on Chrome
// ==UserScript==
// @name KTS
// @namespace onedollarlesson.com
// @description onedollarlesson.com
// @include http://onedollarlesson.com/
// @version 1
// @run-at document-idle
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.js
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_getValue
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_notification
// @run-at document-idle
// @icon http://onedollarlesson.com/favicon.png
// ==/UserScript==
function simulateKeyPress() {
Podium = {};
Podium.keydown = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'which', {
get : function() {
return this.keyCodeVal;
}
});
if (oEvent.initKeyboardEvent) {
oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, k, k, "", "", false, "");
} else {
oEvent.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, k, 0);
}
oEvent.keyCodeVal = k;
if (oEvent.keyCode !== k) {
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
}
document.body.dispatchEvent(oEvent);
};
Podium.keydown(40); // for arrow-down, arrow-up is 38
}
var multiKey = function() {
for (var i = 0; i < 10; i++) {
simulateKeyPress();
}
};
var call_func = function(callback) {
callback();
};
var getKey = function() {
if ($('div .page-current').hasClass('page-6') !== true) {
call_func(function () {
multiKey();
});
console.log("Press");
}
else {
if ($("#page-6-choose-1").hasClass('checked') !== true){
call_func(function () {
$("div #page-6-choose-1 span").click();
console.log("Click lesson 1");
});
}
else if( ($("div .page-6-choose").hasClass('unclick') === true) && (($("#page-6-choose-1").hasClass('checked') === true) || ($("#page-6-choose-2").hasClass('checked') === true)) ){
for (var n = 0; n < 3; n++){
setTimeout(function(){
call_func(function () {
multiKey();
});
},500);
}
}
else if ($("#page-6-choose-2").hasClass('checked') !== true){
call_func(function () {
$("div #page-6-choose-2 span").click();
console.log("Click lesson 2");
});
}
else if ($("#page-6-choose-3").hasClass('checked') !== true) {
call_func(function () {
$("div #page-6-choose-3 span").click();
console.log("Click lesson 3");
});
}
else {
if ($('div .page-current .page-6-download').hasClass('active') === true ) {
return true;
}
else {
console.log("Nothing to do");
}
}
}
};
function getCall () {
var timer = getKey();
if (timer !== true) {
setTimeout(getCall, 5000);
}
else {
clearTimeout(getCall);
}
}
$("#wrap").ready(function (){
getCall();
$(document).click(function(evt) {
if ($('div .page-current .page-6-download').hasClass('active') === true ) {
console.log("Open promo link");
var url = $('div #kaspersky-download-trial').attr('href');
url = 'http://onedollarlesson.com' + url;
var win = window.open(url, '_blank');
win.focus();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment