| Index: lib/elemHide.js |
| =================================================================== |
| --- a/lib/elemHide.js |
| +++ b/lib/elemHide.js |
| @@ -81,17 +81,17 @@ |
| /** |
| * Returns a list of selectors that apply on each website unconditionally. |
| * @returns {string[]} |
| */ |
| function getUnconditionalSelectors() |
| { |
| if (!unconditionalSelectors) |
| - unconditionalSelectors = [...filterBySelector.keys()]; |
| + unconditionalSelectors = Object.freeze([...filterBySelector.keys()]); |
| return unconditionalSelectors; |
| } |
| ElemHideExceptions.on("added", ({selector}) => |
| { |
| // If this is the first exception for a previously unconditionally applied |
| // element hiding selector we need to take care to update the lookups. |
| @@ -231,13 +231,18 @@ |
| if (currentDomain == "") |
| break; |
| let nextDot = currentDomain.indexOf("."); |
| currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
| } |
| if (!specificOnly) |
| - selectors = getUnconditionalSelectors().concat(selectors); |
| + { |
| + // Avoid making a copy if there are no domain-specific selectors. |
| + selectors = selectors.length > 0 ? |
| + getUnconditionalSelectors().concat(selectors) : |
| + getUnconditionalSelectors(); |
| + } |
| return selectors; |
| } |
| }; |