function makeProperty(name, varname) {
return "'" + name + "' in window.agar || " +
"Object.defineProperty( window.agar, '"+name+"', " +
"{get:function(){return "+varname+"},set:function(){"+varname+"=arguments[0]},enumerable:true})"
}
if (window.top != window.self)
return
if (document.readyState !== 'loading')
return console.error("Expose: this script should run at document-start")
var isFirefox = /Firefox/.test(navigator.userAgent)
// Stage 1: Find corresponding rule
var rules
for (var i = 0; i < allRules.length; i++)
if (allRules[i].hostname.indexOf(window.location.hostname) !== -1) {
rules = allRules[i]
break
}
if (!rules)
return console.error("Expose: cant find corresponding rule")
// Stage 2: Search for main_out.js
if (isFirefox) {
function bse_listener(e) { tryReplace(e.target, e) }
window.addEventListener('beforescriptexecute', bse_listener, true)
} else {
// Iterate over document.head child elements and look for main_out.js
for (var i = 0; i < document.head.childNodes.length; i++)
if (tryReplace(document.head.childNodes[i]))
return
// If there are no desired element in document.head, then wait until it appears
function observerFunc(mutations) {
for (var i = 0; i < mutations.length; i++) {
var addedNodes = mutations[i].addedNodes
for (var j = 0; j < addedNodes.length; j++)
if (tryReplace(addedNodes[j]))
return observer.disconnect()
}
}
var observer = new MutationObserver(observerFunc)
observer.observe(document.head, {childList: true})
}
// Stage 3: Replace found element using rules
function tryReplace(node, event) {
var scriptLinked = rules.scriptUriRe && rules.scriptUriRe.test(node.src)
var scriptEmbedded = rules.scriptTextRe && rules.scriptTextRe.test(node.textContent)
if (node.tagName != "SCRIPT" || (!scriptLinked && !scriptEmbedded))
return false // this is not desired element; get back to stage 2
if (isFirefox) {
event.preventDefault()
window.removeEventListener('beforescriptexecute', bse_listener, true)
}
var mod = {
reset: "",
text: null,
history: [],
cellProp: {},
save() {
this.history.push({reset:this.reset, text:this.text})
return true
},
restore() {
var state = this.history.pop()
this.reset = state.reset
this.text = state.text
return true
},
reset_(reset) {
this.reset += reset
return true
},
replace(what, from, to, reset) {
var vars = [], hooks = []
what.split(" ").forEach((x) => {
x = x.split(":")
x[0] === "var" && vars.push(x[1])
x[0] === "hook" && hooks.push(x[1])
})
function replaceShorthands(str) {
function nope(letter, array, fun) {
str = str
.split(new RegExp('\\$' + letter + '([0-9]?)'))
.map((v,n) => n%2 ? fun(array[v||0]) : v)
.join("")
}
nope('v', vars, (name) => "window.agar." + name)
nope('h', hooks, (name) => "window.agar.hooks." + name)
nope('H', hooks, (name) =>
"window.agar.hooks." + name + "&&" +
"window.agar.hooks." + name)
return str
}
var newText = this.text.replace(from, replaceShorthands(to))
if(newText === this.text) {
console.error("Expose: `" + what + "` replacement failed!")
return false
} else {
this.text = newText
if (reset)
this.reset += replaceShorthands(reset) + ";"
return true
}
},
removeNewlines() {
this.text = this.text.replace(/([,\/;])\n/mg, "$1")
},
get: function() {
var cellProp = JSON.stringify(this.cellProp)
return `window.agar={hooks:{},cellProp:${cellProp}};` +
this.reset + this.text
}
}
if (scriptEmbedded) {
mod.text = node.textContent
rules.replace(mod)
if (isFirefox) {
document.head.removeChild(node)
var script = document.createElement("script")
script.textContent = mod.get()
document.head.appendChild(script)
} else {
node.textContent = mod.get()
}
console.log("Expose: replacement done")
} else {
document.head.removeChild(node)
var request = new XMLHttpRequest()
request.onload = function() {
var script = document.createElement("script")
mod.text = this.responseText
rules.replace(mod)
script.textContent = mod.get()
// `main_out.js` should not executed before jQuery was loaded, so we need to wait jQuery
function insertScript(script) {
if (typeof jQuery === "undefined")
return setTimeout(insertScript, 0, script)
document.head.appendChild(script)
console.log("Expose: replacement done")
}
insertScript(script)
}
request.onerror = function() { console.error("Expose: response was null") }
request.open("get", node.src, true)
request.send()
}
return true
// ==UserScript== // @name Raga bots // @namespace http://tweenkapy.tk // @version 1.0 // @description Tweenkapy agar.io bots // @author Tweenkapy // @match http://agar.io/* // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js // @grant none // @run-at document-start // ==/UserScript==
setTimeout(function() { var real_minx = -7071; var real_miny = -7071; var real_maxx = 7071; var real_maxy = 7071; var lastsent = { minx: 0, miny: 0, maxx: 0, maxy: 0 };
$( "#canvas" ).after( "
Minions: Offline
" ); socket.on('spawn-count', function(data) { document.getElementById('minionCount').innerHTML = data }); var client_uuid = localStorage.getItem('client_uuid'); if (client_uuid == null) { console.log("generating a uuid for this user"); client_uuid = ""; var ranStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (var ii = 0; ii < 15; ii++) client_uuid += ranStr.charAt(Math.floor(Math.random() * ranStr.length)); localStorage.setItem('client_uuid', client_uuid) } socket.emit("login", client_uuid); $("#instructions").replaceWith('
}, 5000);
var allRules = [ { hostname: ["agar.io"], scriptUriRe: /^http:\/\/agar.io\/main_out.js/, replace: function (m) { m.removeNewlines()
]
function makeProperty(name, varname) { return "'" + name + "' in window.agar || " + "Object.defineProperty( window.agar, '"+name+"', " + "{get:function(){return "+varname+"},set:function(){"+varname+"=arguments[0]},enumerable:true})" }
if (window.top != window.self) return
if (document.readyState !== 'loading') return console.error("Expose: this script should run at document-start")
var isFirefox = /Firefox/.test(navigator.userAgent)
// Stage 1: Find corresponding rule var rules for (var i = 0; i < allRules.length; i++) if (allRules[i].hostname.indexOf(window.location.hostname) !== -1) { rules = allRules[i] break } if (!rules) return console.error("Expose: cant find corresponding rule")
// Stage 2: Search for
main_out.js
if (isFirefox) { function bse_listener(e) { tryReplace(e.target, e) } window.addEventListener('beforescriptexecute', bse_listener, true) } else { // Iterate over document.head child elements and look formain_out.js
for (var i = 0; i < document.head.childNodes.length; i++) if (tryReplace(document.head.childNodes[i])) return // If there are no desired element in document.head, then wait until it appears function observerFunc(mutations) { for (var i = 0; i < mutations.length; i++) { var addedNodes = mutations[i].addedNodes for (var j = 0; j < addedNodes.length; j++) if (tryReplace(addedNodes[j])) return observer.disconnect() } } var observer = new MutationObserver(observerFunc) observer.observe(document.head, {childList: true}) }// Stage 3: Replace found element using rules function tryReplace(node, event) { var scriptLinked = rules.scriptUriRe && rules.scriptUriRe.test(node.src) var scriptEmbedded = rules.scriptTextRe && rules.scriptTextRe.test(node.textContent) if (node.tagName != "SCRIPT" || (!scriptLinked && !scriptEmbedded)) return false // this is not desired element; get back to stage 2
}