Martin said:
(e-mail address removed) wrote:
If your own document is loaded locally (from a file: URL) in Firefox
then it is possible to try to request privileges from the user e.g.
var iframe = document.createElement('iframe');
iframe.addEventListener(
'load',
function (evt) {
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
var p = iframe.contentDocument.createElement('p');
p.appendChild(iframe.contentDocument.createTextNode(
'Kibology for all.'));
iframe.contentDocument.body.appendChild(p);
}
catch (e) {
// deal with not getting privilege here
}
},
false
);
iframe.src = '
http://www.mozilla.org/';
iframe.width = '100%';
iframe.height = '300';
document.body.appendChild(iframe);
If your own document is loaded via HTTP then with normal security
settings your script can't request privileges in Mozilla. You would need
signed script in that case.
Hey Martin, thanks for that fantastic post, along with your followup.
I have a related question that's been on my mind. I've been using
GreaseMonkey, and what I've got is a local file (on my Win XP Pro hard
drive) such that when I double click it, Firefox comes up with it.
GreaseMonkey has been set to act on that file and so it does its thing
(the file on the hard drive is a dummy file. Its only point is that GM
keys on it to start the relevant GM script).
So here is my (two part) question. First: is there some kind of
privilege that I could set so that I can do a window.close() to close
down the page that I thusly brought up (I should add that the GM script
will cause other pages to be loaded in the original page's place, and
each subsequent page will also be subject to the same GM script - in
this fashion I am sequencing through pages)? I haven't worked with
privileges before. If there is some privilege that I can set, could
that privilege be set on an automated basis before Firefox is invoked
(I am effectively asking where this privilege lives) using (for
example) PHP (perhaps by editing some configuration file)? Perhaps an
extension could accomplish my goal if privilege mucking can't?
Second: assuming that the first question has a Yes answer, I would
really like the instance of FF started off by means of the double click
on my initial local file to stay hidden. This is because I want to
schedule FF to act upon that file (and hence invoke a GM script) so
that I shouldn't be distracted as this is going on.
Essentially, I want to be able to automate sequencing through web pages
on an automated basis using FF instead of IE. With IE I use VBScript
to create a hidden instance of IE, and then the VBScript gets notified
when the requested page has loaded. At that point, the script can muck
about with the loaded page using VBScript. The FF approach would allow
me to muck about with the page using the more natural javascript. And
my only remaining issues are cleanup and page visibility.
Thanks,
Csaba Gabor from Vienna