| Index: lib/content/elemHideEmulation.js |
| diff --git a/chrome/content/elemHideEmulation.js b/lib/content/elemHideEmulation.js |
| similarity index 93% |
| rename from chrome/content/elemHideEmulation.js |
| rename to lib/content/elemHideEmulation.js |
| index 447a479a6fc9e835291506c7a3127b809d17a4de..cfbaf1080c0989be1a1c17c47ac721a003ea60bd 100644 |
| --- a/chrome/content/elemHideEmulation.js |
| +++ b/lib/content/elemHideEmulation.js |
| @@ -15,51 +15,13 @@ |
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| -/* globals filterToRegExp */ |
| - |
| "use strict"; |
| +const {filterToRegExp, splitSelector} = require("common"); |
| + |
| const MIN_INVOCATION_INTERVAL = 3000; |
| const abpSelectorRegexp = /:-abp-([\w-]+)\(/i; |
| -function splitSelector(selector) |
| -{ |
| - if (selector.indexOf(",") == -1) |
| - return [selector]; |
| - |
| - let selectors = []; |
| - let start = 0; |
| - let level = 0; |
| - let sep = ""; |
| - |
| - for (let i = 0; i < selector.length; i++) |
| - { |
| - let chr = selector[i]; |
| - |
| - if (chr == "\\") // ignore escaped characters |
| - i++; |
| - else if (chr == sep) // don't split within quoted text |
| - sep = ""; // e.g. [attr=","] |
| - else if (sep == "") |
| - { |
| - if (chr == '"' || chr == "'") |
| - sep = chr; |
| - else if (chr == "(") // don't split between parentheses |
| - level++; // e.g. :matches(div,span) |
| - else if (chr == ")") |
| - level = Math.max(0, level - 1); |
| - else if (chr == "," && level == 0) |
| - { |
| - selectors.push(selector.substring(start, i)); |
| - start = i + 1; |
| - } |
| - } |
| - } |
| - |
| - selectors.push(selector.substring(start)); |
| - return selectors; |
| -} |
| - |
| /** Return position of node from parent. |
| * @param {Node} node the node to find the position of. |
| * @return {number} One-based index like for :nth-child(), or 0 on error. |
| @@ -512,3 +474,6 @@ ElemHideEmulation.prototype = { |
| }); |
| } |
| }; |
| + |
| +exports.ElemHideEmulation = ElemHideEmulation; |
| +exports.splitSelector = splitSelector; |
|
hub
2017/08/16 16:14:46
do we still need this since it is exported from co
kzar
2017/08/17 12:40:21
Done.
|