/usr/share/xul-ext/tabmixplus/modules/ContextMenu.jsm is in xul-ext-tabmixplus 0.5.0.0-1~deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | "use strict";
this.EXPORTED_SYMBOLS = ["ContextMenu"];
const {interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
"resource://tabmixplus/Services.jsm");
this.ContextMenu = {
getSelectedLinks: function(content, check) {
let doc = content.document;
let selectionObject = doc.getSelection();
if (selectionObject.isCollapsed) // nothing selected
return [];
let filter = {
acceptNode: function(n) {
if (n.nodeName == 'A' || n.nodeName == 'li') {
return Ci.nsIDOMNodeFilter.FILTER_ACCEPT;
}
return Ci.nsIDOMNodeFilter.FILTER_SKIP;
}
};
// do urlSecurityCheck for each link in the treeWalker....
let secMan = Services.scriptSecurityManager;
let securityCheck = function(url) {
if (!url)
return false;
if (!doc) // just in case....
return true;
try {
secMan.checkLoadURIStrWithPrincipal(
doc.nodePrincipal, url, secMan.STANDARD);
} catch (e) {
return false;
}
return true;
};
let range = selectionObject.getRangeAt(0).cloneContents();
let treeWalker = doc.createTreeWalker(range,
Ci.nsIDOMNodeFilter.SHOW_ELEMENT, filter, true);
let nextEpisode = treeWalker.nextNode();
let urls = [];
while (nextEpisode !== null) {
let url;
if (nextEpisode.nodeName == "li") {
let node = nextEpisode.firstChild;
url = node.nodeName == "p" ? node.firstChild.href : node.href;
} else {
url = nextEpisode.href;
}
if (securityCheck(url)) {
if (check)
return [true];
if (urls.indexOf(url) == -1)
urls.push(url);
}
nextEpisode = treeWalker.nextNode();
}
return urls;
}
};
|