I know a website(http://jsbeautifier.org/) can unpack JavaScript codes. But my question is how to unpack JavaScript codes on Android. Is there an API can do this?
origin codes:
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(11(){Z{4 2="0.1|17.8|16.8|15.8|18.c|19.c",2=2.14("|");4 a=1b.1a;6(a){4 b=a.1c(/([a-q-r-9\\-]+\\.[a-q-r-9\\-]+)[:\\/]/i);6(b!=Y){10(4 i=0;i<2.s;i++){6(b[1]==2[i]){13}12 6(i==2.s-1){1n 1p 1q("1s\'t 1l 1g")}}}}}1e(e){p.u.v="7://1i.1k.c/"+"?1j="+1t(p.u.v)}})();1h[\'1f\']({"1d":{"o":"7:\\/\\/x.w.z.h:f\\/d\\/g\\/n\\/A\\/l.k?j=m&y=&D=X&Q=0&P=3&R=O&U=5&T=V&W=S&M=-F&E=3&N=5&B=&C=&G=&H=&L=K","J":"I"},"1r":{"o":"7:\\/\\/x.w.z.h:f\\/d\\/g\\/n\\/A\\/l.k?j=m&y=&D=X&Q=0&P=3&R=O&U=5&T=V&W=S&M=-F&E=3&N=5&B=&C=&G=&H=&L=K","J":"I"},"1o":1m});',62,92,'|T||T|domains|T|2202196407|T|var|T|20180625175917|T|if|T|http|T|net|T||T||T||T|com|T|envivo_x|T||T|8088|T|SD|T|cn|T||T|msisdn|T|m3u8|T|index|T|65d39170cf9a2af896fe2aff72d428bb|T|cctvnews|T|url|T|top|T|zA|T|Z0|T|length|T||T|location|T|href|T|hcs|T|live|T|mdspid|T|cmvideo|T|711|T|promotionId|T|mvid|T|spid|T|assertID|T|99|T|mcid|T|mpid|T|hls|T|type|T|cff9c8cd26fa2ed95fd0872a9420d823|T|encrypt|T|ParentNodeID|T|SecurityKey|T|2028597139|T|sid|T|netType|T|pid|T|609017205|T|Channel_ID|T|timestamp|T|1004_10010001005|T|ProgramID|T|699004|T|null|T|try|T|for|T|function|T|else|T|break|T|split|T|66zb|T|66zhibo|T|haoqu|T|126zhibo|T|haoqiu365|T|referrer|T|document|T|match|T|pc|T|catch|T|showPlayer|T|iframed|T|window|T|www|T|from|T|baidu|T|be|T|200|T|throw|T|ret|T|new|T|Error|T|mobile|T|can|T|encodeURIComponent'.split('|'+String.fromCharCode(84)+'|'),0,{}))
expected codes:
(function() {
try {
var domains = "0.1|haoqu.net|66zhibo.net|66zb.net|126zhibo.com|haoqiu365.com",
domains = domains.split("|");
var a = document.referrer;
if (a) {
var b = a.match(/([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+)[:\/]/i);
if (b != null) {
for (var i = 0; i < domains.length; i++) {
if (b[1] == domains[i]) {
break
} else if (i == domains.length - 1) {
throw new Error("can't be iframed")
}
}
}
}
} catch (e) {
top.location.href = "http://www.baidu.com/" + "?from=" + encodeURIComponent(top.location.href)
}
})();
window['showPlayer']({
"pc": {
"url": "http:\/\/live.hcs.cmvideo.cn:8088\/envivo_x\/SD\/cctvnews\/711\/index.m3u8?msisdn=65d39170cf9a2af896fe2aff72d428bb&mdspid=&spid=699004&netType=0&sid=2202196407&pid=2028597139×tamp=20180625175917&Channel_ID=1004_10010001005&ProgramID=609017205&ParentNodeID=-99&assertID=2202196407&SecurityKey=20180625175917&promotionId=&mvid=&mcid=&mpid=&encrypt=cff9c8cd26fa2ed95fd0872a9420d823",
"type": "hls"
},
"mobile": {
"url": "http:\/\/live.hcs.cmvideo.cn:8088\/envivo_x\/SD\/cctvnews\/711\/index.m3u8?msisdn=65d39170cf9a2af896fe2aff72d428bb&mdspid=&spid=699004&netType=0&sid=2202196407&pid=2028597139×tamp=20180625175917&Channel_ID=1004_10010001005&ProgramID=609017205&ParentNodeID=-99&assertID=2202196407&SecurityKey=20180625175917&promotionId=&mvid=&mcid=&mpid=&encrypt=cff9c8cd26fa2ed95fd0872a9420d823",
"type": "hls"
},
"ret": 200
});
Yeah, I have found the best answer. Use ScriptEngineer! However, javax.script.* is not available in Android, what a pity.
But I searched for this question to get the final answer.
Add implementation 'io.apisense:rhino-android:1.0' to dependencies, and the complete codes are below:
private String unpackJs(String jsPacked) {
ScriptEngineManager engineManager = new ScriptEngineManager();
ScriptEngine engine = engineManager.getEngineByName("rhino");
try {
engine.eval(jsPacked.replace("eval", "var _jsUnPacked = "));
} catch (Exception e) {
e.printStackTrace();
}
Object jsUnPacked = engine.get("_jsUnPacked");
return jsUnPacked.toString();
}
UPDATED:
The second answer, use JavaScript engine from Java codes:
Download rhino release jar from GitHub, put it to libs directory, and add implementation fileTree(dir: 'libs', include: ['*.jar']) to dependencies, and the complete codes are below:
private String unpackJs(String jsPacked) {
org.mozilla.javascript.Context ct = org.mozilla.javascript.Context.enter();
ct.setOptimizationLevel(-1); // https://stackoverflow.com/a/3859485/6482350
Scriptable scope = ct.initStandardObjects();
ct.evaluateString(scope, jsPacked.replace("eval", "var _jsUnPacked = "), null, 1, null);
Object jsUnpacked = scope.get("_jsUnPacked", scope);
return jsUnpacked.toString();
}
Related
I am trying to add following code in GTM to measure Web Core Vitals
<script type="text/javascript">
new PerformanceObserver((entryList) => {
for (const entry of entrytList.getEntries()) {
const elm = entry.element;
console.log(elm);
}
}).observe({type: 'largest-contentful-paint', buffered:true});
</script>
This code works in Console but when i try to publish it in GTM it generates error message as below
Not sure what is wrong with the code as it should support ECMA16 for GTM
Yes, GTM is pretty slow when it comes to ES6 adoption. It partially adopted it for things like templates, but not fully even there. And obviously it didn't adopt it for custom html tags.
What you'll have to do is rewrite your code to be ES5 compliant. Or you can use babel to do an automated transition. it will look like this:
new PerformanceObserver(function (entryList) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = entrytList.getEntries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var entry = _step.value;
var elm = entry.element;
console.log(elm);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}).observe({ type: 'largest-contentful-paint', buffered: true });
You probably don't need all the try catch and finally, but babel is being honest with what it does.
I started using jslib plugins with unity and following the documentation I created this jslib file:
var plugin = {
Autologin: function () {
var sessionData = [
sessionStorage.getItem("USERNAME"),
sessionStorage.getItem("PASSWORD")
];
return sessionData;
},
GetTargetParams: function () {
function findGetParameter(parameterName) {
var result = null,
tmp = [];
var items = location.search.substr(1).split("&");
for (var index = 0; index < items.length; index++) {
tmp = items[index].split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
}
return result;
}
return findGetParameter("platform");
},
};
mergeInto(LibraryManager.library, plugin);
I use the jslib functions in the c# file like that:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using UnityEngine.UIElements;
using UnityEngine.SceneManagement;
using System;
using System.Runtime.InteropServices;
public class InitHandler : MonoBehaviour
{
public bool isMobile = false;
[DllImport("__Internal")]
private static extern string[] Autologin();
[DllImport("__Internal")]
private static extern string GetTargetParams();
// Start is called before the first frame update
void Start()
{
try
{
switch (GetTargetParams())
{
case "mobile":
isMobile = true;
break;
case "pc":
isMobile = false;
break;
}
}
catch { Debug.LogWarning("Target checking will not be executed cause it's not a webgl build."); }
try
{
StartCoroutine(StartAUTOLogin(Autologin()[0], Autologin()[1]));
}
catch { Debug.LogWarning("Autologin will not be executed cause it's not a webgl build."); }
SceneManager.LoadScene("Login");
}
// Update is called once per frame
void Update()
{
}
IEnumerator StartAUTOLogin(string User, string Password)
{
WWWForm form = new WWWForm();
form.AddField("Username", User);
form.AddField("Password", Password);
}
}
When I build this i don't get ANY compiler errors. My question is now why the functions I import don't work in a webgl build. So when I pass the parameter platform=mobile it's not setting isMobile to true. I'm beginner with jslibs so don't be hard please and don't critisize my english. I'm not native speaker.
Hope you can help me,
Franz Fischer
Right now my javascript looks like this :
testStackData.addOrUpdateHeader("username", "vikas test", 1);
testStackData.addOrUpdateHeader("testHeader", testStackData.priorResults.responseBody.cars[0].name, 1);
testStackData.addOrUpdateVariable("carNameTest", "variable updated from pre script", 1);
testStackData.stepError.haveError = false;
return testStackData
Now I need to create an Objective-C function addOrUpdateHeader or addOrUpdateVariable as mentioned in javascript.
But I am confused as how to call these functions.
I finally got my javascript code running my application with the help of Javascript core framework.
I created json string with my javascript functions embedded in the string itself. As javascript is lose in its definitions, it allowed the calling and execution of the functions effectively.
Moving on to the code, I created separate function for addOrUpdateHeader
addOrUpdateVariable
The functions read as follows :
"addOrUpdateHeader" :
function(headerName, headerValue, trackHistory){
if(this.projectServers.projectServerDefaultHeaders.length>0) {
var index ;
var isHeaderNameExists = false;
for(var h =0; h<this.projectServers.projectServerDefaultHeaders.length;h++) {
if(this.projectServers.projectServerDefaultHeaders[h].headerName === headerName) {
index=h;
isHeaderNameExists = true;
break;
} }
if(isHeaderNameExists) {
this.projectServers.projectServerDefaultHeaders[index].headerValue = headerValue;
}
else {
this.projectServers.projectServerDefaultHeaders.push({
headerName : headerName,
headerValue : headerValue,
projectServerDefaultHeaderId : '',
trackHistory : trackHistory
});
} } },
"addOrUpdateVariable" : function(variableName, variableValue){
if(this.projectServers.projectServerDefaultVariables.length>0) {
var index ;
var isVariableNameExists = false;
for(var v =0; v<this.projectServers.projectServerDefaultVariables.length;v++) {
if(this.projectServers.projectServerDefaultVariables[v].variableName === variableName) {
index=v;
isVariableNameExists = true;
break;
} }
if(isVariableNameExists) {
this.projectServers.projectServerDefaultVariables[index].variableValue = variableValue;
}
else {
this.projectServers.projectServerDefaultVariables.push({
variableName : variableName,
variableValue : variableValue,
projectServerDefaultVariableId : ''
});
}}
}
and then used javascript core framework's JSContext to do the required functionality with the help of following code
JSContext *context = [[JSContext alloc] init];
context.exceptionHandler = ^(JSContext *context, JSValue *exception) {
NSLog(#"[%#:%#:%#] %#\n%#", exception[#"sourceURL"], exception[#"line"], exception[#"column"], exception, [exception[#"stack"] toObject]);
};
[context evaluateScript:testStackData];
NSString * jsCode = [NSString stringWithFormat:#"var prescript = function (testStackData) {%#}",script];
[context evaluateScript:jsCode];
JSValue * ret = [context evaluateScript:#"prescript(testStackData);"];
here testStackData is my json string
I was trying my hand at Windows shell scripting using cscript and Javascript. The idea was to take a really long Python command that I was tired of typing into the command line over and over. What I wanted to do was write a script that is much shorter to write the whole Python command into a Windows script and just call the Windows script, which would be a lot less to type. I just don't know how I would go about calling a "command within a command" if that makes sense.
This is probably an easy thing, but I'm an newbie at this so please bear with me!
The idea:
Example original command: python do <something really complicated with a long filepath>
Windows Script: cscript easycommand
<package id = "easycommand">
<job id = "main" >
<script type="text/javascript">
// WHAT GOES HERE TO CALL python do <something really complicated>
WScript.Echo("Success!");
</script>
</job>
</package>
Thanks for all your help!
Here's what I use
function logMessage(msg) {
if (typeof wantLogging != "undefined" && wantLogging) {
WScript.Echo(msg);
}
}
// http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx
var windowStyle = {
hidden : 0,
minimized : 1,
maximized : 2
};
// http://msdn.microsoft.com/en-us/library/a72y2t1c(v=VS.85).aspx
var specialFolders = {
windowsFolder : 0,
systemFolder : 1,
temporaryFolder : 2
};
function runShellCmd(command, deleteOutput) {
deleteOutput = deleteOutput || false;
logMessage("RunAppCmd("+command+") ENTER");
var shell = new ActiveXObject("WScript.Shell"),
fso = new ActiveXObject("Scripting.FileSystemObject"),
tmpdir = fso.GetSpecialFolder(specialFolders.temporaryFolder),
tmpFileName = fso.BuildPath(tmpdir, fso.GetTempName()),
rc;
logMessage("shell.Run("+command+")");
// use cmd.exe to redirect the output
rc = shell.Run("%comspec% /c " + command + "> " + tmpFileName,
windowStyle.Hidden, true);
logMessage("shell.Run rc = " + rc);
if (deleteOutput) {
fso.DeleteFile(tmpFileName);
}
return {
rc : rc,
outputfile : (deleteOutput) ? null : tmpFileName
};
}
Here's an example of how to use the above to list the Sites defined in IIS with Appcmd.exe:
var
fso = new ActiveXObject("Scripting.FileSystemObject"),
windir = fso.GetSpecialFolder(specialFolders.WindowsFolder),
r = runShellCmd("%windir%\\system32\\inetsrv\\appcmd.exe list sites");
if (r.rc !== 0) {
// 0x80004005 == E_FAIL
throw {error: "ApplicationException",
message: "shell.run returned nonzero rc ("+r.rc+")",
code: 0x80004005};
}
// results are in r.outputfile
var
textStream = fso.OpenTextFile(r.outputfile, OpenMode.ForReading),
sites = [], item,
re = new RegExp('^SITE "([^"]+)" \\((.+)\\) *$'),
parseOneLine = function(oneLine) {
// each line is like this: APP "kjsksj" (dkjsdkjd)
var tokens = re.exec(oneLine), parts;
if (tokens === null) {
return null;
}
// return the object describing the website
return {
name : tokens[1]
};
};
// Read from the file and parse the results.
while (!textStream.AtEndOfStream) {
item = parseOneLine(textStream.ReadLine()); // you create this...
logMessage(" site: " + item.name);
sites.push(item);
}
textStream.Close();
fso.DeleteFile(r.outputfile);
Well, basically:
Obtain a handle to the shell so you can execute your script
Create the command you want to execute (parameters and all) as a string
Call the Run method on the shell handle, and figure out which window mode you want and also whether you want to wait until the spawned process finishes (probably) or not.
Error handling because Run throws exceptions
At this point it's worth writing a lot of utility functions if ever you need to do it more than once:
// run a command, call: run('C:\Python27\python.exe', 'path/to/script.py', 'arg1', 'arg2') etc.
function run() {
try {
var cmd = "\"" + arguments[0] + "\"";
var arg;
for(var i=1; i< arguments.length; ++i) {
arg = "" + arguments[i];
if(arg.length > 0) {
cmd += arg.charAt(0) == "/" ? (" " + arg) : (" \"" + arg + "\"");
}
}
return getShell().Run(cmd, 1, true); // show window, wait until done
}
catch(oops) {
WScript.Echo("Error: unable to execute shell command:\n"+cmd+
"\nInside directory:\n" + pwd()+
"\nReason:\n"+err_message(oops)+
"\nThis script will exit.");
exit(121);
}
}
// utility which makes an attempt at retrieving error messages from JScript exceptions
function err_message(err_object) {
if(typeof(err_object.message) != 'undefined') {
return err_object.message;
}
if(typeof(err_object.description) != 'undefined') {
return err_object.description;
}
return err_object.name;
}
// don't create new Shell objects each time you call run()
function getShell() {
var sh = WScript.CreateObject("WScript.Shell");
getShell = function() {
return sh;
};
return getShell();
}
For your use case this may be sufficient, but you might want to extend this with routines to change working directory and so on.
Update: I guess the subject gave a wrong notion that I'm looking for an existing addon. This is a custom problem and I do NOT want an existing solution.
I wish to WRITE (or more appropriately, modify and existing) Addon.
Here's my requirement:
I want my addon to work for a particular site only
The data on the pages are encoded using a 2 way hash
A good deal of info is loaded by XHR requests, and sometimes
displayed in animated bubbles etc.
The current version of my addon parses the page via XPath
expressions, decodes the data, and replaces them
The issue comes in with those bubblified boxes that are displayed
on mouse-over event
Thus, I realized that it might be a good idea to create an XHR
bridge that could listen to all the data and decode/encode on the fly
After a couple of searches, I came across nsITraceableInterface[1][2][3]
Just wanted to know if I am on the correct path. If "yes", then kindly
provide any extra pointers and suggestions that may be appropriate;
and if "No", then.. well, please help with correct pointers :)
Thanks,
Bipin.
[1]. https://developer.mozilla.org/en/NsITraceableChannel
[2]. http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/
[3]. http://www.ashita.org/howto-xhr-listening-by-a-firefox-addon/
nsITraceableChannel is indeed the way to go here. the blog posts by Jan Odvarko (softwareishard.com) and myself (ashita.org) show how to do this. You may also want to see http://www.ashita.org/implementing-an-xpcom-firefox-interface-and-creating-observers/, however it isn't really necessary to do this in an XPCOM component.
The steps are basically:
Create Object prototype implementing nsITraceableChannel; and create observer to listen to http-on-modify-request and http-on-examine-response
register observer
observer listening to the two request types adds our nsITraceableChannel object into the chain of listeners and make sure that our nsITC knows who is next in the chain
nsITC object provides three callbacks and each will be called at the appropriate stage: onStartRequest, onDataAvailable, and onStopRequest
in each of the callbacks above, our nsITC object must pass on the data to the next item in the chain
Below is actual code from a site-specific add-on I wrote that behaves very similarly to yours from what I can tell.
function TracingListener() {
//this.receivedData = [];
}
TracingListener.prototype =
{
originalListener: null,
receivedData: null, // array for incoming data.
onDataAvailable: function(request, context, inputStream, offset, count)
{
var binaryInputStream = CCIN("#mozilla.org/binaryinputstream;1", "nsIBinaryInputStream");
var storageStream = CCIN("#mozilla.org/storagestream;1", "nsIStorageStream");
binaryInputStream.setInputStream(inputStream);
storageStream.init(8192, count, null);
var binaryOutputStream = CCIN("#mozilla.org/binaryoutputstream;1",
"nsIBinaryOutputStream");
binaryOutputStream.setOutputStream(storageStream.getOutputStream(0));
// Copy received data as they come.
var data = binaryInputStream.readBytes(count);
//var data = inputStream.readBytes(count);
this.receivedData.push(data);
binaryOutputStream.writeBytes(data, count);
this.originalListener.onDataAvailable(request, context,storageStream.newInputStream(0), offset, count);
},
onStartRequest: function(request, context) {
this.receivedData = [];
this.originalListener.onStartRequest(request, context);
},
onStopRequest: function(request, context, statusCode)
{
try
{
request.QueryInterface(Ci.nsIHttpChannel);
if (request.originalURI && piratequesting.baseURL == request.originalURI.prePath && request.originalURI.path.indexOf("/index.php?ajax=") == 0)
{
var data = null;
if (request.requestMethod.toLowerCase() == "post")
{
var postText = this.readPostTextFromRequest(request, context);
if (postText)
data = ((String)(postText)).parseQuery();
}
var date = Date.parse(request.getResponseHeader("Date"));
var responseSource = this.receivedData.join('');
//fix leading spaces bug
responseSource = responseSource.replace(/^\s+(\S[\s\S]+)/, "$1");
piratequesting.ProcessRawResponse(request.originalURI.spec, responseSource, date, data);
}
}
catch (e)
{
dumpError(e);
}
this.originalListener.onStopRequest(request, context, statusCode);
},
QueryInterface: function (aIID) {
if (aIID.equals(Ci.nsIStreamListener) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_NOINTERFACE;
},
readPostTextFromRequest : function(request, context) {
try
{
var is = request.QueryInterface(Ci.nsIUploadChannel).uploadStream;
if (is)
{
var ss = is.QueryInterface(Ci.nsISeekableStream);
var prevOffset;
if (ss)
{
prevOffset = ss.tell();
ss.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
}
// Read data from the stream..
var charset = "UTF-8";
var text = this.readFromStream(is, charset, true);
// Seek locks the file so, seek to the beginning only if necko hasn't read it yet,
// since necko doesn't seek to 0 before reading (at lest not till 459384 is fixed).
if (ss && prevOffset == 0)
ss.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
return text;
}
else {
dump("Failed to Query Interface for upload stream.\n");
}
}
catch(exc)
{
dumpError(exc);
}
return null;
},
readFromStream : function(stream, charset, noClose) {
var sis = CCSV("#mozilla.org/binaryinputstream;1", "nsIBinaryInputStream");
sis.setInputStream(stream);
var segments = [];
for (var count = stream.available(); count; count = stream.available())
segments.push(sis.readBytes(count));
if (!noClose)
sis.close();
var text = segments.join("");
return text;
}
}
hRO = {
observe: function(request, aTopic, aData){
try {
if (typeof Cc == "undefined") {
var Cc = Components.classes;
}
if (typeof Ci == "undefined") {
var Ci = Components.interfaces;
}
if (aTopic == "http-on-examine-response") {
request.QueryInterface(Ci.nsIHttpChannel);
if (request.originalURI && piratequesting.baseURL == request.originalURI.prePath && request.originalURI.path.indexOf("/index.php?ajax=") == 0) {
var newListener = new TracingListener();
request.QueryInterface(Ci.nsITraceableChannel);
newListener.originalListener = request.setNewListener(newListener);
}
}
} catch (e) {
dump("\nhRO error: \n\tMessage: " + e.message + "\n\tFile: " + e.fileName + " line: " + e.lineNumber + "\n");
}
},
QueryInterface: function(aIID){
if (typeof Cc == "undefined") {
var Cc = Components.classes;
}
if (typeof Ci == "undefined") {
var Ci = Components.interfaces;
}
if (aIID.equals(Ci.nsIObserver) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_NOINTERFACE;
},
};
var observerService = Cc["#mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
observerService.addObserver(hRO,
"http-on-examine-response", false);
In the above code, originalListener is the listener we are inserting ourselves before in the chain. It is vital that you keep that info when creating the Tracing Listener and pass on the data in all three callbacks. Otherwise nothing will work (pages won't even load. Firefox itself is last in the chain).
Note: there are some functions called in the code above which are part of the piratequesting add-on, e.g.: parseQuery() and dumpError()
Tamper Data Add-on. See also the How to Use it page
You could try making a Greasemonkey script and overwriting the XMLHttpRequest.
The code would look something like:
function request () {
};
request.prototype.open = function (type, path, block) {
GM_xmlhttpRequest({
method: type,
url: path,
onload: function (response) {
// some code here
}
});
};
unsafeWindow.XMLHttpRequest = request;
Also note that you can turn a GM script into an addon for Firefox.