Skip to content

Instantly share code, notes, and snippets.

@shanechin
Last active December 11, 2015 21:28
Show Gist options
  • Save shanechin/4662233 to your computer and use it in GitHub Desktop.
Save shanechin/4662233 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name PissApOff
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @include http://fifa1404.herokuapp.com/view/1
// @include http://fifa1404.herokuapp.com/
// @copyright 2012+, You
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main() {
jQ(function(){
var fourhours = 14400000;
var testtime = 1000;
Array.prototype.shuffle = function () {
for (var i = this.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var tmp = this[i];
this[i] = this[j];
this[j] = tmp;
}
return this;
}
setInterval(
function(){
var names = new Array("B.C. ","Jonny","Shane","Skanda", "Steve");
var prob = new Array(80, 65, 60, 40, 10);
var scores = new Array(4, 3, 2, 1, 0);
var randIndexOne = Math.floor((Math.random()*4));
var randIndexTwo = Math.floor((Math.random()*4));
while(randIndexTwo == randIndexOne){
randIndexTwo = Math.floor((Math.random()*4));
}
while(randIndexTwo == randIndexOne){
randIndexTwo = Math.floor((Math.random()*4));
}
scores = scores.shuffle();
largescore = scores[randIndexOne] > scores[randIndexTwo] ? scores[randIndexOne] : scores[randIndexTwo];
smallscore = scores[randIndexOne] > scores[randIndexTwo] ? scores[randIndexTwo] : scores[randIndexOne];
var skewedWinner = Math.floor((Math.random()*100));
console.log(skewedWinner);
jQ("#player1_name").val(names[randIndexOne]);
jQ("#player2_name").val(names[randIndexTwo]);
if(skewedWinner < prob[randIndexOne]){
jQ('#player1_score').val(largescore);
jQ('#player2_score').val(smallscore);
}
else{
jQ('#player1_score').val(smallscore);
jQ('#player2_score').val(largescore);
}
var aTags = document.getElementsByTagName("button");
var searchText = "Enter Result";
for (var i = 0; i < aTags.length; i < il) {
if (aTags[i].innerHTML == searchText) {
var found = aTags[i];
break;
}
}
$(found).click();
console.log(names[randIndexOne] + " " + jQ('#player1_score').val());
console.log(names[randIndexTwo] + " " + jQ('#player2_score').val());
},fourhours);
});
}
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment