fixup for Chrome 49 without Symbol.iterator

This commit is contained in:
tophf 2017-04-15 13:25:48 +03:00
parent e61a24b4e4
commit aaa50d6b7b
2 changed files with 11 additions and 7 deletions

View File

@ -261,9 +261,10 @@ function initDocRewriteObserver() {
}; };
// detect documentElement being rewritten from inside the script // detect documentElement being rewritten from inside the script
docRewriteObserver = new MutationObserver(mutations => { docRewriteObserver = new MutationObserver(mutations => {
for (const mutation of mutations) { for (let m = mutations.length; --m >= 0;) {
for (const node of mutation.addedNodes) { const added = mutations[m].addedNodes;
if (node.localName == 'html') { for (let n = added.length; --n >= 0;) {
if (added[n].localName == 'html') {
reinjectStyles(); reinjectStyles();
return; return;
} }

View File

@ -143,14 +143,17 @@ function getResource(url) {
function rebrand(mutations) { function rebrand(mutations) {
/* stylish to stylus; https://github.com/schomery/stylish-chrome/issues/12 */ /* stylish to stylus; https://github.com/schomery/stylish-chrome/issues/12 */
for (const mutation of mutations) { for (let m = mutations.length; --m >= 0;) {
for (const addedNode of mutation.addedNodes) { const added = mutations[m].addedNodes;
for (let n = added.length; --n >= 0;) {
const addedNode = added[n];
if (addedNode.nodeType != Node.ELEMENT_NODE) { if (addedNode.nodeType != Node.ELEMENT_NODE) {
continue; continue;
} }
const elementsToCheck = addedNode.matches('.install-status') ? [addedNode] const elementsToCheck = addedNode.matches('.install-status') ? [addedNode]
: Array.prototype.slice.call(addedNode.getElementsByClassName('install-status')); : addedNode.getElementsByClassName('install-status');
for (const el of elementsToCheck) { for (let i = elementsToCheck.length; --i >= 0;) {
const el = elementsToCheck[i];
if (!el.textContent.includes('Stylish')) { if (!el.textContent.includes('Stylish')) {
continue; continue;
} }