Update Several Files
This commit is contained in:
parent
de6bf545fd
commit
338bc3ed29
@ -2,7 +2,6 @@
|
|||||||
@author Ian Hickey, Rylan Doherty, David Westgate, William Jellesma, Peter Atashian
|
@author Ian Hickey, Rylan Doherty, David Westgate, William Jellesma, Peter Atashian
|
||||||
@fileOverview The event listener, event handler, script writer, and script executer functions of firerecord
|
@fileOverview The event listener, event handler, script writer, and script executer functions of firerecord
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
var recording2 = false;
|
var recording2 = false;
|
||||||
var path = null;
|
var path = null;
|
||||||
@ -11,165 +10,192 @@ var i = 0;
|
|||||||
var line1 = new Array();
|
var line1 = new Array();
|
||||||
var line2 = new Array();
|
var line2 = new Array();
|
||||||
var playThis;
|
var playThis;
|
||||||
|
var debugging = 0; //Turn on debugging by setting this to 1.
|
||||||
|
var lastPage = "";
|
||||||
|
/*
|
||||||
|
* debug handles displaying popups for additional info
|
||||||
|
* needed for debugging purposes.
|
||||||
|
* @arg debug string to display to in debug mode.
|
||||||
|
*/
|
||||||
|
var debug = function (debugString) {
|
||||||
|
if (this.debugging == 1) { alert(debugString) }
|
||||||
|
else { return 1; }
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
* Handles calling the init function on each page load.
|
||||||
|
*/
|
||||||
window.addEventListener("load", function load(event) {
|
window.addEventListener("load", function load(event) {
|
||||||
window.removeEventListener("load", load, false);
|
window.removeEventListener("load", load, false);
|
||||||
firerecord.init();
|
firerecord.init();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init checks that the dom is loaded an ready before calling run()
|
||||||
|
*/
|
||||||
var firerecord = function () {
|
var firerecord = function () {
|
||||||
var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
|
var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
return {
|
return {
|
||||||
init : function() {
|
init: function () {
|
||||||
var appcontent = document.getElementById("appcontent"); // browser
|
var appcontent = document.getElementById("appcontent"); // browser
|
||||||
if (appcontent) {
|
if (appcontent) {
|
||||||
appcontent.addEventListener("DOMContentLoaded", firerecord.run,
|
appcontent.addEventListener("DOMContentLoaded", firerecord.run,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
@author Rylan
|
@author Rylan
|
||||||
*/
|
*/
|
||||||
running : function() {
|
running: function () {
|
||||||
if (recording2) {
|
if (recording2) {
|
||||||
recording2 = false;
|
recording2 = false;
|
||||||
alert("Stop Listen");
|
alert("Recording Completed.");
|
||||||
openUILinkIn(window.content.location.href, "current");
|
openUILinkIn(window.content.location.href, "current");
|
||||||
} else {
|
} else {
|
||||||
recording2 = true;
|
recording2 = true;
|
||||||
alert("Start Listen");
|
alert("Recording On.");
|
||||||
firerecord.run();
|
firerecord.run();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openfile : function() {
|
openfile: function () {
|
||||||
path = io.openPath();
|
path = io.openPath();
|
||||||
},
|
},
|
||||||
newfile : function() {
|
newfile: function () {
|
||||||
path = io.newPath();
|
path = io.newPath();
|
||||||
io.createFile(path);
|
io.createFile(path);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@author Rylan
|
@author Rylan
|
||||||
*/
|
*/
|
||||||
checkpage : function() {
|
checkpage: function () {
|
||||||
page = window.content.location.href;
|
page = window.content.location.href;
|
||||||
if (page != line1)
|
if (page == lastPage) {
|
||||||
openUILinkIn(line1, "current");
|
//do nothing
|
||||||
|
}
|
||||||
setTimeout(function(){
|
else if (page != line1) {
|
||||||
firerecord.fire();
|
openUILinkIn(line1, "current");
|
||||||
},5000);
|
}
|
||||||
},
|
setTimeout(function () {
|
||||||
|
firerecord.fire();
|
||||||
|
}, 3000);//Change timeout to 3 seconds.
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@author Rylan, David
|
@author Rylan, David
|
||||||
*/
|
*/
|
||||||
playback : function() {
|
playback: function () {
|
||||||
i = 0;
|
i = 0;
|
||||||
playThis = io.getScript(path);
|
playThis = io.getScript(path);
|
||||||
line1 = playThis[0];
|
line1 = playThis[0];
|
||||||
line2 = playThis[0+1].split(' :: ');
|
debug("Line 1 == " + line1);
|
||||||
firerecord.checkpage();
|
line2 = playThis[0 + 1].split(' :: ');
|
||||||
},
|
debug("Line 2 == " + line2);
|
||||||
|
//Keep a copy of the last address so we don't refresh the page in the middle of trying to login to a site etc.
|
||||||
|
lastPage = line1;
|
||||||
|
firerecord.checkpage();
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@author Rylan
|
* This function
|
||||||
*/
|
*@author Rylan
|
||||||
fire : function() {
|
*/
|
||||||
if (line2[0]=="key"){
|
fire: function () {
|
||||||
var obj = document.createEvent("KeyboardEvent");
|
if (line2[0] == "key") {
|
||||||
obj.initKeyEvent('keydown', true, true, window, false, false, false, false, 8, 0);
|
debug("Line2 does == [key]");
|
||||||
document.dispatchEvent(obj);
|
var obj = document.createEvent("KeyboardEvent");
|
||||||
}
|
obj.initKeyEvent('keypress', true, true, window, false, false, false, false, 8, 0);
|
||||||
else{
|
var keyResult = document.dispatchEvent(obj);
|
||||||
var all = content.document.getElementsByTagName(line2[1]);
|
debug(keyResult); //Display true or false depending on if another obj has overriden and canceled this event.
|
||||||
for ( var n = 0; n < all.length; n++) {
|
|
||||||
var elem = all[n];
|
}
|
||||||
var searchCount = 0;
|
else {
|
||||||
if(line2[0]=="click")
|
var all = content.document.getElementsByTagName(line2[1]);
|
||||||
searchCount = 2;
|
for (var n = 0; n < all.length; n++) {
|
||||||
else if(line2[0]=="type")
|
var elem = all[n];
|
||||||
searchCount = 3;
|
var searchCount = 0;
|
||||||
var finding = false;
|
if (line2[0] == "click")
|
||||||
while(searchCount<line2.length ){
|
searchCount = 2;
|
||||||
if(elem[line2[searchCount]]==line2[searchCount+1])
|
else if (line2[0] == "type")
|
||||||
{
|
searchCount = 3;
|
||||||
finding = true;
|
var finding = false;
|
||||||
searchCount+=2;
|
while (searchCount < line2.length) {
|
||||||
}
|
if (elem[line2[searchCount]] == line2[searchCount + 1]) {
|
||||||
else{
|
finding = true;
|
||||||
finding = false;
|
searchCount += 2;
|
||||||
break;
|
}
|
||||||
}
|
else {
|
||||||
}
|
finding = false;
|
||||||
if (finding == true)
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
if (finding == false){
|
if (finding == true)
|
||||||
alert("Matching Element Not Found!");
|
break;
|
||||||
}
|
}
|
||||||
else if(line2[0]=="click"){
|
if (finding == false) {
|
||||||
var obj = document.createEvent("MouseEvents");
|
debug("Matching Element Not Found!");
|
||||||
obj.initEvent("click", true, true);
|
}
|
||||||
elem.dispatchEvent(obj);
|
else if (line2[0] == "click") {
|
||||||
}
|
var obj = document.createEvent("MouseEvents");
|
||||||
else if(line2[0]=="type")
|
obj.initEvent("click", true, true);
|
||||||
elem.value = line2[2];
|
elem.dispatchEvent(obj);
|
||||||
i+=2
|
}
|
||||||
if(i<playThis.length){
|
else if (line2[0] == "type")
|
||||||
line1 = playThis[i];
|
elem.value = line2[2];
|
||||||
line2 = playThis[i+1].split(' :: ');
|
i += 2
|
||||||
setTimeout(function(){
|
if (i < playThis.length) {
|
||||||
firerecord.checkpage()
|
line1 = playThis[i];
|
||||||
},5000);
|
line2 = playThis[i + 1].split(' :: ');
|
||||||
}
|
setTimeout(function () {
|
||||||
}
|
firerecord.checkpage()
|
||||||
},
|
}, 3000);
|
||||||
/*
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/*
|
||||||
@author David, Peter, Rylan, Ian
|
@author David, Peter, Rylan, Ian
|
||||||
@description Find all elements attributes and add a listener
|
@description Find all elements attributes and add a listener
|
||||||
*/
|
*/
|
||||||
run : function() {
|
run: function () {
|
||||||
|
|
||||||
var head = content.document.getElementsByTagName("head")[0], style = content.document
|
var head = content.document.getElementsByTagName("head")[0], style = content.document
|
||||||
.getElementById("link-target-finder-style"), all = content.document
|
.getElementById("link-target-finder-style"), all = content.document
|
||||||
.getElementsByTagName("*"), foundElements = 0;
|
.getElementsByTagName("*"), foundElements = 0;
|
||||||
var Recording = true;
|
var Recording = true;
|
||||||
var info = new Array();
|
var info = new Array();
|
||||||
if (!style) {
|
if (!style) {
|
||||||
style = content.document.createElement("link");
|
style = content.document.createElement("link");
|
||||||
style.id = "link-target-finder-style";
|
style.id = "link-target-finder-style";
|
||||||
style.type = "text/css";
|
style.type = "text/css";
|
||||||
style.rel = "stylesheet";
|
style.rel = "stylesheet";
|
||||||
style.href = "chrome://firerecord/skin/skin.css";
|
style.href = "chrome://firerecord/skin/skin.css";
|
||||||
head.appendChild(style);
|
head.appendChild(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recording2) {
|
if (recording2) {
|
||||||
window.content.addEventListener("keyup", handleKey, false);
|
window.content.addEventListener("keyup", handleKey, false);
|
||||||
for ( var i = 0; i < all.length; ++i) {
|
for (var i = 0; i < all.length; ++i) {
|
||||||
elm = all[i];
|
elm = all[i];
|
||||||
var validtags = [ "A", "BUTTON", "FORM", "IMG", "INPUT",
|
var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT",
|
||||||
"LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA" ];
|
"LINK", "OPTION", "SELECT", "SPAN", "TABLE", "TEXTAREA"];
|
||||||
info[0] = all[i].tagName;
|
info[0] = all[i].tagName;
|
||||||
if (validtags.indexOf(info[0]) == -1)
|
if (validtags.indexOf(info[0]) == -1)
|
||||||
continue;
|
continue;
|
||||||
else{
|
else {
|
||||||
if ( (elm.type == "text"||elm.type =="password") && info[0] == "INPUT"){
|
if ((elm.type == "text" || elm.type == "password") && info[0] == "INPUT" || elm.type == "submit" || elm.type == "email") {
|
||||||
elm.className += ((elm.className.length > 0) ? " " : "")
|
elm.className += ((elm.className.length > 0) ? " " : "")
|
||||||
+ "link-target-finder-selected";
|
+ "link-target-finder-selected";
|
||||||
elm.addEventListener("change", handleType, false);
|
elm.addEventListener("change", handleType, false);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
elm.className += ((elm.className.length > 0) ? " " : "")
|
elm.className += ((elm.className.length > 0) ? " " : "")
|
||||||
+ "link-target-finder-selected";
|
+ "link-target-finder-selected";
|
||||||
elm.addEventListener("click", handleEvent, false);
|
elm.addEventListener("click", handleEvent, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -177,53 +203,80 @@ var firerecord = function () {
|
|||||||
@description handles click events
|
@description handles click events
|
||||||
*/
|
*/
|
||||||
function handleEvent(e) {
|
function handleEvent(e) {
|
||||||
var targ;
|
var targ;
|
||||||
if (!e) {
|
if (!e) {
|
||||||
var e = window.event;
|
var e = window.event;
|
||||||
}
|
}
|
||||||
if (e.target) {
|
if (e.target) {
|
||||||
targ = e.target;
|
targ = e.target;
|
||||||
} else if (e.srcElement) {
|
} else if (e.srcElement) {
|
||||||
targ = e.srcElement;
|
targ = e.srcElement;
|
||||||
}
|
}
|
||||||
var eleArray= ["href","name","id","type","value","form","length",
|
var eleArray = ["href", "name", "id", "type", "value",
|
||||||
"target","action","src","charset","text","index",
|
"form", "length", "target", "action",
|
||||||
"caption","size","summary"];
|
"src", "charset", "text", "index",
|
||||||
var validtags = [ "A", "BUTTON", "FORM", "IMG", "INPUT",
|
"caption", "selected", "size", "summary", "class"];
|
||||||
"LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA" ];
|
var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT",
|
||||||
var toWrite = new Array();
|
"LINK", "OPTION", "SELECT", "SPAN", "TABLE", "EM", "TEXTAREA"];
|
||||||
toWrite[0] = "click";
|
var toWrite = new Array();
|
||||||
toWrite[1] = targ.tagName;
|
toWrite[0] = "click";
|
||||||
var countWrite = 2;
|
toWrite[1] = targ.tagName;
|
||||||
var eleCount = 0;
|
var countWrite = 2;
|
||||||
var eleHolder;
|
var eleCount = 0;
|
||||||
if (validtags.indexOf(toWrite[1]) == -1)
|
var eleHolder;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
if (validtags.indexOf(toWrite[1]) == -1) {
|
||||||
else{
|
debug("No valid tags.");
|
||||||
while(eleCount<eleArray.length)
|
}
|
||||||
{
|
else {
|
||||||
|
|
||||||
eleHolder = targ[eleArray[eleCount]];
|
// If we are dealing with a span and can't find the href
|
||||||
if(eleHolder){
|
// we need to look at the parent and get the link...
|
||||||
toWrite[countWrite] = eleArray[eleCount];
|
// Need to add img to this as well if the image has no href of its own...
|
||||||
countWrite+=1;
|
if (toWrite[1] == "SPAN" || toWrite[1] == "EM") {
|
||||||
toWrite[countWrite] = eleHolder;
|
//Find parent.
|
||||||
countWrite+=1;
|
debug("Finding Parent");
|
||||||
}
|
var targP = targ.parentElement;
|
||||||
eleCount += 1;
|
//Loop through parents...
|
||||||
}
|
try {
|
||||||
|
if (targP.tagName != "A") {
|
||||||
|
//Try a second time...
|
||||||
|
targP = targP.parentElement;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debug("Couldn't find and parent with a link: " + e);
|
||||||
|
}
|
||||||
|
var targPtag = targP.tagName;
|
||||||
|
debug("Found " + targPtag);
|
||||||
|
toWrite[1] = targPtag;
|
||||||
|
targ = targP;
|
||||||
|
|
||||||
var contents = toWrite.join(' :: ') + "\n";
|
}
|
||||||
io.appendPath(path, window.content.location.href + "\n");
|
while (eleCount < eleArray.length) {
|
||||||
io.appendPath(path, contents);
|
|
||||||
e.cancelBubble = true;
|
eleHolder = targ[eleArray[eleCount]];
|
||||||
toWrite=[];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
if (eleHolder) {
|
||||||
|
toWrite[countWrite] = eleArray[eleCount];
|
||||||
|
countWrite += 1;
|
||||||
|
toWrite[countWrite] = eleHolder;
|
||||||
|
countWrite += 1;
|
||||||
|
}
|
||||||
|
eleCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var contents = toWrite.join(' :: ') + "\n";
|
||||||
|
io.appendPath(path, window.content.location.href + "\n");
|
||||||
|
debug(window.content.location.href + "\n");
|
||||||
|
io.appendPath(path, contents);
|
||||||
|
debug(contents);
|
||||||
|
e.cancelBubble = true;
|
||||||
|
toWrite = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}();
|
}();
|
||||||
@ -232,95 +285,82 @@ var firerecord = function () {
|
|||||||
@description handles typing
|
@description handles typing
|
||||||
*/
|
*/
|
||||||
function handleType(e) {
|
function handleType(e) {
|
||||||
var targ;
|
var targ;
|
||||||
if (!e) {
|
if (!e) {
|
||||||
var e = window.event;
|
var e = window.event;
|
||||||
}
|
}
|
||||||
if (e.target) {
|
if (e.target) {
|
||||||
targ = e.target;
|
targ = e.target;
|
||||||
} else if (e.srcElement) {
|
} else if (e.srcElement) {
|
||||||
targ = e.srcElement;
|
targ = e.srcElement;
|
||||||
}
|
}
|
||||||
var eleArray= ["href","name","id","type","form","length",
|
var eleArray = ["href", "name", "id", "type", "form", "length",
|
||||||
"target","action","src","charset","text","index",
|
"target", "action", "src", "charset", "text", "index",
|
||||||
"caption","size","summary"];
|
"caption", "selected", "size", "summary", "class"];
|
||||||
var validtags = [ "A", "BUTTON", "FORM", "IMG", "INPUT",
|
var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT",
|
||||||
"LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA" ];
|
"LINK", "OPTION", "SELECT", "SPAN", "TABLE", "TEXTAREA"];
|
||||||
var toWrite = new Array();
|
var toWrite = new Array();
|
||||||
toWrite[0] = "type";
|
toWrite[0] = "type";
|
||||||
toWrite[1] = targ.tagName;
|
toWrite[1] = targ.tagName;
|
||||||
toWrite[2] = targ.value;
|
toWrite[2] = targ.value;
|
||||||
var countWrite = 3;
|
var countWrite = 3;
|
||||||
var eleCount = 0;
|
var eleCount = 0;
|
||||||
var eleHolder;
|
var eleHolder;
|
||||||
if (validtags.indexOf(toWrite[1]) == -1)
|
if (validtags.indexOf(toWrite[1]) == -1) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
while(eleCount<eleArray.length)
|
while (eleCount < eleArray.length) {
|
||||||
{
|
eleHolder = targ[eleArray[eleCount]];
|
||||||
eleHolder = targ[eleArray[eleCount]];
|
if (eleHolder) {
|
||||||
if(eleHolder){
|
toWrite[countWrite] = eleArray[eleCount];
|
||||||
toWrite[countWrite] = eleArray[eleCount];
|
countWrite += 1;
|
||||||
countWrite+=1;
|
toWrite[countWrite] = eleHolder;
|
||||||
toWrite[countWrite] = eleHolder;
|
countWrite += 1;
|
||||||
countWrite+=1;
|
}
|
||||||
}
|
eleCount += 1;
|
||||||
eleCount += 1;
|
}
|
||||||
}
|
if (targ.value) {
|
||||||
if(targ.value){
|
var contents = toWrite.join(' :: ') + "\n";
|
||||||
var contents = toWrite.join(' :: ') + "\n";
|
io.appendPath(path, window.content.location.href + "\n");
|
||||||
io.appendPath(path, window.content.location.href + "\n");
|
io.appendPath(path, contents);
|
||||||
io.appendPath(path, contents);
|
e.cancelBubble = true;
|
||||||
e.cancelBubble = true;
|
toWrite = [];
|
||||||
toWrite=[];
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@author Rylan
|
@author Rylan
|
||||||
@description handles key events
|
@description handles key events
|
||||||
*/
|
*/
|
||||||
function handleKey(e){
|
function handleKey(e) {
|
||||||
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
var e = window.event;
|
var e = window.event;
|
||||||
}
|
}
|
||||||
if (e.target) {
|
if (e.target) {
|
||||||
targ = e.target;
|
targ = e.target;
|
||||||
} else if (e.srcElement) {
|
} else if (e.srcElement) {
|
||||||
targ = e.srcElement;
|
targ = e.srcElement;
|
||||||
}
|
}
|
||||||
var validkeys = [13,9,32,27,8];
|
var validkeys = [13, 9];
|
||||||
var keyHit = e? e.which: window.event.keyCode;
|
var keyHit = e ? e.which : window.event.keyCode;
|
||||||
if (validkeys.indexOf(keyHit) == -1)
|
if (validkeys.indexOf(keyHit) == -1) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
|
|
||||||
var toWrite = new Array();
|
var toWrite = new Array();
|
||||||
toWrite[0] = "key";
|
toWrite[0] = "key";
|
||||||
|
|
||||||
if(keyHit == 13){
|
if (keyHit == 13) {
|
||||||
toWrite[1] = "enter";
|
toWrite[1] = "enter";
|
||||||
}
|
}
|
||||||
else if(keyHit == 9){
|
else if (keyHit == 9) {
|
||||||
toWrite[1] = "tab";
|
toWrite[1] = "tab";
|
||||||
}
|
}
|
||||||
else if(keyHit == 32){
|
var contents = toWrite.join(' :: ') + "\n";
|
||||||
toWrite[1] = "space";
|
io.appendPath(path, window.content.location.href + "\n");
|
||||||
}
|
io.appendPath(path, contents);
|
||||||
else if(keyHit === 27){
|
}
|
||||||
toWrite[1] = "esc";
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(keyHit == 8){
|
|
||||||
toWrite[1] = "backspace";
|
|
||||||
}
|
|
||||||
var contents = toWrite.join(' :: ') + "\n";
|
|
||||||
io.appendPath(path, window.content.location.href + "\n");
|
|
||||||
io.appendPath(path, contents);
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user