Hacking _root variables with Firefox
While i'm new to root vars myself. I made a little script to insert an easy way to do root var hacking, as I didn't want to go through the trouble of trying to do it with CE.
Caution should be used when hacking multiplayer games that save data and have ban systems. This changes any var to string. Which could result in values being combined rather than added. Which could result in bans. Use at your own risk in these situations
-----------------
This requires the Greasemonkey Extension.
What this script will do is Place 2 input fields, 1 for the Var Name, and one for the Value to set. Simply click submit to change it.
Simply enough really.
UserScript Code
-----------------
DO NOT use the "Select All" button on the code tab, it will cause every line to be prefixed by 4 spaces, which will cause the script to import incorrectly. Just Select it yourself then copy.
// ==UserScript==
// @name Kongregate Root Var Hacking
// @namespace Infamousblob
// @description Easy way hack with root vars
// @include http://*.kongregate.com/games/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @version 0.2
// @date 2010-03-10
// ==/UserScript==
//Only loads this code on the main window
if(window.top == window.self)
{
//Increase's window size to show the form
var gameiframe = document.getElementById('gameiframe');
var maingame = document.getElementById('maingame');
maingame.style.height = parseInt(maingame.style.height) + 30 + 'px';
gameiframe.height = Math.min(gameiframe.height) + 30;
}
else
{
// Inserts Jquery and Jquery UI into the iframe header, so it can be utilized and anything else JQ we need
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
var GM_JQUI = document.createElement('script');
GM_JQUI.src = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js';
GM_JQUI.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
document.getElementsByTagName('head')[0].appendChild(GM_JQUI);
var CSS = '<style type="text/css">';
CSS += '#rv_hack_box { background-color:#3D3D3D; border:1px #1D1D1D solid;padding:5px; width:25px; color:#fff; position:relative; }';
CSS += '#rv_hack_form { display:none; }';
CSS += '#rv_draghandle { background-color:#000; border:1px #1D1D1D solid; color:#fff; padding:3px; font-size:8px; float:left; }';
CSS += '#rv_hide { background-color:#000; border:1px #1D1D1D solid; color:#fff; padding:3px; font-size:8px; float:right; }';
CSS += '</style>'
$('head').append(CSS);
//This makes the Flash Object Transparent so HTML can float over it
$('#gamediv').append('<param name="wmode" value="transparent" />');
//JS to run it all
var RV_JS = '<script type="text/javascript">';
RV_JS += 'var rv_intervals = new Array();'
RV_JS += 'function rv_change(varname,varvalue){document.getElementById("gamediv").SetVariable("_root."+varname,varvalue);}function rv_freeze(varname,varvalue){if(rv_intervals[varname])clearInterval(rv_intervals[varname]);if(varname==""||varvalue=="")return;rv_intervals[varname]=setInterval("rv_change('"+varname+"', '"+varvalue+"')",1);}function rv_unfreeze(varname){clearInterval(rv_intervals[varname]);}';
RV_JS += '$(function() { ';
RV_JS += '$("#rv_hack_box").draggable({ snap: "#game_wrapper", handle: "#rv_draghandle" });';
//RV_JS += '$("#rv_hack_box").position({top:"-400px" });alert($(window).height());'
RV_JS += '$("#rv_draghandle").hover(function() { $(this).css("cursor","move"); }, function() { $(this).css("cursor","auto");});';
RV_JS += '$("#rv_hide").hover(function() { $(this).css("cursor","pointer"); }, function() { $(this).css("cursor","auto");});';
RV_JS += '$("#rv_hide").toggle(function(){$(this).text("-").attr("title", "Hide");$("#rv_hack_form").show();$("#rv_hack_box").width(100);},function(){$(this).text("+").attr("title", "Show");$("#rv_hack_form").hide();$("#rv_hack_box").width(25);});';
RV_JS += '$("#rv_change").click(function() { document.getElementById("gamediv").SetVariable("_root."+$("#varname").val(), $("#varvalue").val()); });';
RV_JS += '$("#rv_freeze").click(function() { rv_freeze($("#varname").val(), $("#varvalue").val());});';
RV_JS += '$("#rv_unfreeze").click(function() { rv_unfreeze($("#varname").val());});';
RV_JS += '});';
RV_JS += '</script>';
$('#game_wrapper').append(RV_JS);
//HMTL for it all
var RV_HTML = '<div id="rv_hack_box">';
RV_HTML += '<div id="rv_draghandle" title="Move">+</div><div id="rv_hide" title="Show">+</div><br />';
RV_HTML += '<form action="#maingame" onsubmit="return false;" name="rv_hack_form" id="rv_hack_form">';
RV_HTML += 'Varname: <input id="varname" type="text" size="8" name="varname" /><br />';
RV_HTML += 'Value: <input id="varvalue" type="text" size="8" name="varvalue" /><br />';
RV_HTML += '<input type="button" value="Change" id="rv_change" />';
RV_HTML += '<input type="button" value="Freeze" id="rv_freeze" />';
RV_HTML += '<input type="button" value="UnFreeze" id="rv_unfreeze" />';
RV_HTML += '</form></div>';
$('#game_wrapper').append(RV_HTML);
}
How to Install
-----------------
- Copy the above code.
- Create a file named something.user.js
- Open with a Text Editor of your choice.
- Paste the above code into it.
- Save it.
- Drag the JS file into the page area of Firefox
- When prompted "install" the script.
How to Upgrade
-----------------
Version 0.1 to 0.2
Do Not just Edit the file and copy the new code in, I added a require (Jquery). So it requires to be re-installed. To do this just repeat the install steps above. Future versions should not need to do this, and may just edit the script and paste in.
How to use
-----------------
The menu will appear in the bottom left under the game. You will initially see 2 +'s Left one is for draggin the box around (will snap to the flash windows edge's), the right will Toogle Show/Hide
--Basics
-----------------
The var will already be prefixed with "_root." so all you need is the var name itself
Example: Mad Karate Man - Mad Points
The Rootvar you would use for Cheat Engine is "_level0/:cash" so what we need is after the _level0/: which is "cash"
Enter "cash" as the var name and whatever value you want. Click submit.
And poof your Mad Points have change
--Freezing
-----------------
New feature allows you to freeze values. This is done every 1 millisecond.
Simply enter your information like normal and click Freeze.
Var's will stay frozen unless you Unfreeze them by clicking unfreeze.
If you decide later to unfreeze a var after you have already changed it, simply just enter the name in again and click unfreeze
Notes
-----------------
If you see root vars listed with " _root." just ignore this part instead.
It does seem maybe some games are compiled with script access denied, which will prevent this method from working.
Changelog
-----------------
2010-03-10
- Updated to ver 0.2
- Reworked the code majorly
- Added Jquery and Jquery UI injections into Kongregate Iframe
- Added Jquery into the script for easier manipulation
- Menu is now Dragable(and snapable to flash window edges), and has Show/Hide Toggle
- Added Freeze/Unfreeze Feature at roughly 1ms intervals
-----------------
Let me know if you have any problems with this
