Skip to content

Instantly share code, notes, and snippets.

@ZebTheWizard
Last active April 20, 2020 04:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZebTheWizard/64f18a97b7542de8432092b193b885e2 to your computer and use it in GitHub Desktop.
Save ZebTheWizard/64f18a97b7542de8432092b193b885e2 to your computer and use it in GitHub Desktop.
A simple javascript function that automatically collects loot on twitch streams.
// COPY AND PASTE ONE OF THE OTHER.
// THE SCRIPT WILL START AUTOMATICALLY.
// USE autoLoot.stop() to stop the script.
// USE autoLoot.every(insertTimeHere) to set how often the script executes.
// USE autoLoot.start() to start the script.
// MINIFIED VERSION
Object.assign(window,{l:console.log,r:console.clear,autoLoot:{i:null,t:5* 1e3,c:0,every:function(t){this.t=t},_c:function(){r(),this.c+=1;try{document.querySelector(".tw-button.tw-button--success.tw-interactive").click(),l(`ATTEMPT ${this.c}: LOOT FOUND!!`)}catch(t){l(`ATTEMPT ${this.c}: no loot`)}},start:function(){if(this.i)return l("Already started. Run autoLoot.stop() to stop.");r(),l("STARTING AUTO LOOT SCRIPT\n================="),this._c(),this.i=setInterval(this._c.bind(this),this.t)},stop:function(){if(!this.i)return l("Already stopped. Run autoLoot.start() to start.");l("STOPPED AUTO LOOT SCRIPT\n================="),this.i=clearInterval(this.i)}}}).autoLoot.start();
// RAW VERSION
(Object.assign(window, {
l: console.log,
r: console.clear,
autoLoot: {
i: null,
t: 1000 * 5,
c: 0,
every: function (ms) {
this.t = ms
},
_c: function () {
r();
this.c += 1;
try {
document
.querySelector(".tw-button.tw-button--success.tw-interactive")
.click();
l(`ATTEMPT ${this.c}: LOOT FOUND!!`);
} catch (err) {
l(`ATTEMPT ${this.c}: no loot`);
}
},
start: function () {
if (this.i) return l("Already started. Run autoLoot.stop() to stop.");
r();
l('STARTING AUTO LOOT SCRIPT\n=================');
this._c();
this.i = setInterval(this._c.bind(this), this.t);
},
stop: function () {
if (!this.i) return l("Already stopped. Run autoLoot.start() to start.");
l('STOPPED AUTO LOOT SCRIPT\n=================');
this.i = clearInterval(this.i);
}
}
})).autoLoot.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment