I want to write a script generator based on whats happening on the website, and for that I have written javascript - ajax based script generator, where on every page i do include the js file and within function block of page where page is submited I call the function of javascript to initiate reading of page variables ( DOM ) by getElementsByTagName(*), and after looping through it, I write predefined format to a file using ajax.
this all is done for the same site where its running, however now as when I needed to implement same for any other site as recorder and script generator as whats done on the website and to log into file, neither I can include my script on to any other external website nor put function call before submit to read dom and throw into file.
here is dummy code of js
beginRecording();
function beginRecording()
{
if(RECORD_BIT == 1)
{
processPageData();
}
}
function processPageData()
{
var i
var obj = document
var posArray = new Array();
var allElement = obj.getElementsByTagName("*");
var dataArrayString = "";
for(i=0; i < allElement.length; i++)
{
if (allElement[i].getAttribute('id') != null && allElement[i].getAttribute('id') != "")
{
posArray[posArray.length] = allElement[i].getAttribute('id');
}
}
for(i = 0 ; i < posArray.length ; i++)
{
dataArrayString = dataArrayString+"SET "+posArray[i]+"="+getValueFromPage(posArray[i]);
}
writePostData(dataArrayString);
}
The function writePostData, does ajax and writes/ updates file on the server by logging what was on DOM element, and I send couple of more details liek GET/POST or page name and so on..
beginRecording() is called on the page before javascript does a submit as document.forms[0].submit(), so that it can capture POST.
I read about cross domain ajax, but still I am not sure how can I monitor HTTP (read GET / POST and data on page or URL) of any external website without adding my script into that file, and write to file
any help or direction would be great.