1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
Components.utils.import('resource://greasemonkey/prefmanager.js');
Components.utils.import('resource://greasemonkey/util.js');
var EXPORTED_SYMBOLS = ['getEditor'];
function getEditor() {
var editorPath = GM_prefRoot.getValue("editor");
if (!editorPath) return null;
var editor = null;
try {
editor = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsIFile);
editor.followLinks = true;
editor.initWithPath(editorPath);
} catch (e) {
GM_util.logError(e, false, e.fileName, e.lineNumber);
}
// make sure the editor preference is still valid
if (!editor || !editor.exists() || !editor.isExecutable()) {
GM_prefRoot.remove("editor");
editor = null;
}
return editor;
}
|