Index: chrome/content/composer.js |
=================================================================== |
--- a/chrome/content/composer.js |
+++ b/chrome/content/composer.js |
@@ -123,31 +123,37 @@ function TreeView_getCellProperties(row, |
this.getRowProperties(row); |
} |
/********************* |
* General functions * |
*********************/ |
function init() { |
- var element = window.arguments[0]; |
- doc = element.ownerDocument; |
- var wnd = doc.defaultView; |
+ let node = window.arguments[0]; |
+ let domain = window.arguments[1]; |
+ if (node instanceof Node) |
+ { |
+ doc = node.ownerDocument; |
+ domain = doc.defaultView.location.hostname; |
+ nodeData = new NodeData(node); |
+ } |
+ else |
+ nodeData = node; |
// Check whether element hiding group is disabled |
let subscription = AdblockPlus.getSubscription("~eh~"); |
if (subscription && subscription.disabled) |
{ |
let warning = document.getElementById("groupDisabledWarning"); |
if (/\?1\?/.test(warning.textContent)) |
warning.textContent = warning.textContent.replace(/\?1\?/g, subscription.title); |
warning.hidden = false; |
} |
- nodeData = new NodeData(element); |
nodeData.tagName.checked = true; |
if (nodeData.attributes.length > 0) |
{ |
let maxLen = 0; |
let bestAttr = null; |
for (let i = 0; i < nodeData.attributes.length; i++) |
{ |
let len = nodeData.attributes[i].value.length; |
@@ -164,17 +170,16 @@ function init() { |
} |
if (bestAttr) |
{ |
bestAttr.selected = bestAttr.value; |
bestAttr.checked = true; |
} |
} |
- let domain = wnd.location.hostname; |
let selectedDomain; |
switch (Prefs.composer_defaultDomain) |
{ |
case 0: |
selectedDomain = ""; |
break; |
case 1: |
try |
@@ -237,17 +242,17 @@ function updateExpression() |
{ |
var op = "*="; |
if (attr.selected == attr.value) |
op = "="; |
else if (attr.value.substr(0, attr.selected.length) == attr.selected) |
op = "^="; |
else if (attr.value.substr(attr.value.length - attr.selected.length) == attr.selected) |
op = "$="; |
- |
+ |
let useFallback = false; |
if (attr.name == "id" && op == "=") |
expression += "#" + escapeName(attr.selected).replace(/^([^a-zA-Z\\])/, escapeChar).replace(/\\(\s)$/, escapeChar); |
else if (attr.name == "class" && /\S/.test(attr.selected)) |
{ |
let knownClasses = new Set(attr.value.split(/\s+/)); |
let classes = attr.selected.split(/\s+/).filter(cls => cls != ""); |
if (classes.every(cls => knownClasses.has(cls))) |