I don't know much about Javascript, but I would like to make a greasemonkey script that does the following:
1. Searches the current HTML document for a certain string and pulls a value from there.. example: "type=hidden value=3918", it would pull the 3918
2. Saves that information to the user's hard drive for later retrieval within the same script.
Is this possible?
Greasemonkey + Javascript- find a string in the current doc?
Moderator: General Moderators
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
From your example it appears you'd better be searching for hidden form elements instead, like this:1. Searches the current HTML document for a certain string and pulls a value from there..
Code: Select all
var hiddens = document.evaluate(
'//input[@type="hidden" and @value]',
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; l = hiddens.snapshotLength; i < l; i++) {
var hidden = hiddens.snapshotItem(i);
// do somethign to hidden
}
That's easy, just use GM_setValue and GM_getValue functions:2. Saves that information to the user's hard drive for later retrieval within the same script.
Code: Select all
// store value:
GM_setValue('name', 'value');
// retrive value:
alert(GM_getValue('name'));
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm