XPCOM, javascript: Current path when executing .js files

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
juanato
Posts: 22
Joined: Sun Sep 25, 2011 4:11 pm

XPCOM, javascript: Current path when executing .js files

Post by juanato » Tue Dec 30, 2014 2:33 pm

Hello all!!

I'm investigating how a played .js file from SandBox-iMacros-Firefox can get the actual executing directory, the path to .js file instead (OR NOT) /iMacros/Macros/"...".
The nsiLocalFile properties cannont detect the current sandbox-iMacros execution... onlye may say where is the defaults directories to the Firefox binary file.. or the plugin loaded inside Firefox (Imacros profiles).


Thanks in advance.. and I wish all a very GOOD 2015 YEAR !!


Using nsiLocalFile, can only inspected the global special names...


ds=Cc["@mozilla.org/file/directory_service;1"];
ds=ds.getService(Ci.nsIProperties);
var libpath=ds.get("Home",Ci.nsILocalFile);


Its possible to call NsiLocalFile or FileUtils to say where is the currented played js file in the sandbox ( maybe overriten the global variables).
User avatar
thecoder2012
Posts: 446
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: XPCOM, javascript: Current path when executing .js files

Post by thecoder2012 » Thu Oct 03, 2019 1:36 pm

juanato wrote:
Tue Dec 30, 2014 2:33 pm
Its possible to call NsiLocalFile or FileUtils to say where is the currented played js file in the sandbox ( maybe overriten the global variables).
I'm unsure. You can grab the currentMacro with or without Path.

Code: Select all

const Cc = Components.classes;
const Ci = Components.interfaces;
var wm = imns.Cc["@mozilla.org/appshell/window-mediator;1"].getService(imns.Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
alert(win.iMacros.currentMacro.name);// with full path: win.iMacros.currentMacro.path
Or the currentprocess path:

Code: Select all

const Cc = Components.classes;
const Ci = Components.interfaces;
alert(Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get('CurProcD', Ci.nsIFile).path);
CurProcD = Current working directory

Tested with WINNT, Basilisk 52.9.2019.09.12 (64-Bit, Build 20190912160707, Vendor Moonchild Productions), iMacros 8.9.7
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:60.9) Gecko/20100101 Goanna/4.4 Firefox/60.9 Basilisk/20190912
(Goanna = Gecko fork)

With Waterfox:
WINNT, Waterfox 56.2.14 (64-Bit, Build 20190902231505, Vendor Mozilla), iMacros 8.9.7
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0 Waterfox/56.2.14

FCI was created with this Code:

Code: Select all

const Cc = Components.classes;
const Ci = Components.interfaces
var info = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULAppInfo);
var os = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
                 .getService(Components.interfaces.nsIXULRuntime);
var bitsys = xulRuntime.is64Bit ? "64-Bit" : "32-Bit";

var testv = xulRuntime.OS+", ";
testv += info.name+" "+info.version+" ("+bitsys+", Build "+info.appBuildID+", Vendor "+info.vendor+"), ";
testv += "iMacros "+imns.Pref.getCharPref("version");
testv += "\n"+window.navigator.userAgent;
alert(testv);
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
Post Reply