Skip to content

Instantly share code, notes, and snippets.

@dwiyatci
Created July 8, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwiyatci/5c8a0cd1176c75089fea to your computer and use it in GitHub Desktop.
Save dwiyatci/5c8a0cd1176c75089fea to your computer and use it in GitHub Desktop.
An anti-collision Kletternmonkey πŸ™ˆ
// ==UserScript==
// @name anticollision-kletternmonkey
// @namespace localhost
// @description My take on "#MoneyTree - das Kletterduell" campaign by O2 (May-July 2015).
// Just for fun (topping myself in the top ten), and not for
// intentionally winning the contest and/or the "Hauptpreis" -
// Schwedenreise fΓΌr zwei im Design-Baumhaus (Gesamtwert 3.000 €).
//
// This should also be a case study showing how bad it is when a JS
// programmer carelessly pollutes the global namespace. =)
//
// @version 2.X
// @grant none
// @include https://kletterduell.o2online.de/menu
// @include https://kletterduell.o2online.de/game*
// @include https://kletterduell.o2online.de/acceptChallenge/*
// @copyright 2015+, Glenn Dwiyatcita
// @require https://code.jquery.com/jquery-latest.js
// @require https://raw.githubusercontent.com/bitovi/legacy-syn/master/dist/syn.js
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
$(function () {
console.info('Kletternmonkey says: "Moin, moin!"');
var interceptTimeout = 500;
window.setTimeout(function () {
window.KG_PhaserCollision = function KG_PhaserCollision(f) {
var e = {
debug: !1
},
d;
return {
init : function (a, b) {
$.extend(e, a);
d = b || null
},
preload : function () {
},
create : function () {
},
update : function () {
},
render : function () {
},
checkGoodieCollision: function (a) {
var b = d.SceneManager.getPlayer(),
c = [];
d.Logic.getGamestate().activePowerup ? (null !== a.hitObjects[0] && c.push(a.hitObjects[0]), null !== a.hitObjects[2] && c.push(a.hitObjects[2])) : (0 < b.scale.x && null !== a.hitObjects[0] && c.push(a.hitObjects[0]), 0 > b.scale.x && null !== a.hitObjects[2] && c.push(a.hitObjects[2]));
null !== a.hitObjects[1] && c.push(a.hitObjects[1]);
return c
},
checkCollision : function (a) {
// var b = d.SceneManager.getPlayer();
// return 0 < b.scale.x && 1 !== a.treeType || 0 > b.scale.x && 2 !== a.treeType ? !1 : !0
console.log('overriding .checkCollision() function. Looks Good To Monkey.');
return false;
}
}
};
console.info('An anti-collision monkey has been dispatched to help you climb the #MoneyTree.');
var phaser = $('#phaser'),
target = phaser.children('canvas'),
superMonkeySpeed = 100;
console.log('target: ' + target[0].outerHTML);
var getRandomInt = function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
},
shakeDaMonkey = NaN;
var control = $('<button>')
.css({
position : 'fixed',
top : 100,
left : 100,
color : 'black',
borderRadius: 4
})
.text('βžͺ @rpl @xan: click here \\_(ツ)_/')
.on('click', function () {
if (isNaN(shakeDaMonkey)) {
shakeDaMonkey = window.setInterval(function () {
var shake = Boolean(getRandomInt(0, 1)) ?
'[left]' : '[right]';
Syn.type(shake, target);
//Syn.click(target);
}, superMonkeySpeed);
} else {
window.clearInterval(shakeDaMonkey);
shakeDaMonkey = NaN;
}
})
.appendTo('body');
}, interceptTimeout);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment