| Index: polyfill.js |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/polyfill.js |
| @@ -0,0 +1,47 @@ |
| +/* |
| + * This file is part of Adblock Plus <https://adblockplus.org/>, |
| + * Copyright (C) 2006-present eyeo GmbH |
| + * |
| + * Adblock Plus is free software: you can redistribute it and/or modify |
| + * it under the terms of the GNU General Public License version 3 as |
| + * published by the Free Software Foundation. |
| + * |
| + * Adblock Plus is distributed in the hope that it will be useful, |
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| + * GNU General Public License for more details. |
| + * |
| + * You should have received a copy of the GNU General Public License |
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| + */ |
| + |
| +"use strict"; |
| + |
| +(function() |
| +{ |
| + // On Edge, the extension APIs are in the "browser" namespace, whereas on |
| + // both Firefox and Chrome they're in the "chrome" namespace. Firefox has a |
| + // "browser" namespace too, but it is slightly incompatible in that the |
| + // implementation uses promises as a fallback in the absence of a callback |
| + // parameter. Edge sometimes has a "chrome" namespace, but with no extension |
| + // APIs. |
| + // |
| + // In order to make the same code run on all three platforms, we simply look |
| + // for a "chrome" namespace with the extension APIs and assign it to the |
| + // "browser" namespace. |
| + if (typeof chrome != "undefined" && "extension" in chrome) |
| + window.browser = chrome; |
| + |
| + // Workaround since HTMLCollection, NodeList, StyleSheet and |
| + // CSSRuleList didn't have iterator support before Chrome 51. |
| + // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 |
| + let arrayIterator = Array.prototype[Symbol.iterator]; |
| + if (!(Symbol.iterator in HTMLCollection.prototype)) |
| + HTMLCollection.prototype[Symbol.iterator] = arrayIterator; |
| + if (!(Symbol.iterator in NodeList.prototype)) |
| + NodeList.prototype[Symbol.iterator] = arrayIterator; |
| + if (!(Symbol.iterator in StyleSheetList.prototype)) |
| + StyleSheetList.prototype[Symbol.iterator] = arrayIterator; |
| + if (!(Symbol.iterator in CSSRuleList.prototype)) |
| + CSSRuleList.prototype[Symbol.iterator] = arrayIterator; |
| +}()); |