From 8e75871b9bf1b6c360e6f1dece9262d4510e6cb8 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 14 Oct 2018 02:19:01 +0800 Subject: [PATCH] Breaking: drop getStylesFallback --- background/background.js | 27 --------------------------- content/apply.js | 23 ----------------------- 2 files changed, 50 deletions(-) diff --git a/background/background.js b/background/background.js index f42168c5..b763b637 100644 --- a/background/background.js +++ b/background/background.js @@ -59,33 +59,6 @@ var browserCommands, contextMenus; // register all listeners msg.on(onRuntimeMessage); -// if (FIREFOX) { - // see notes in apply.js for getStylesFallback - // const MSG_GET_STYLES = 'getStyles:'; - // const MSG_GET_STYLES_LEN = MSG_GET_STYLES.length; - // chrome.runtime.onConnect.addListener(port => { - // if (!port.name.startsWith(MSG_GET_STYLES)) return; - // const tabId = port.sender.tab.id; - // const frameId = port.sender.frameId; - // const options = tryJSONparse(port.name.slice(MSG_GET_STYLES_LEN)); - // port.disconnect(); - // FIXME: getStylesFallback? - // getStyles(options).then(styles => { - // if (!styles.length) return; - // chrome.tabs.executeScript(tabId, { - // code: ` - // applyOnMessage({ - // method: 'styleApply', - // styles: ${JSON.stringify(styles)}, - // }) - // `, - // runAt: 'document_start', - // frameId, - // }); - // }); - // }); -// } - navigatorUtil.onUrlChange(({tabId, frameId}, type) => { if (type === 'committed') { // styles would be updated when content script is injected. diff --git a/content/apply.js b/content/apply.js index 8c4c7796..db142bc6 100644 --- a/content/apply.js +++ b/content/apply.js @@ -36,7 +36,6 @@ const APPLY = (() => { } function init() { - // FIXME: getStylesFallback? if (STYLE_VIA_API) { return API.styleViaAPI({method: 'styleApply'}); } @@ -137,28 +136,6 @@ const APPLY = (() => { return matchUrl; } - /** - * TODO: remove when FF fixes the bug. - * Firefox borks sendMessage in same-origin iframes that have 'src' with a real path on the site. - * We implement a workaround for the initial styleApply case only. - * Everything else (like toggling of styles) is still buggy. - * @param {Object} msg - * @param {Function} callback - * @returns {Boolean|undefined} - */ - // function getStylesFallback(msg) { - // if (window !== parent && - // location.href !== 'about:blank') { - // try { - // if (parent.location.origin === location.origin && - // parent.location.href !== location.href) { - // chrome.runtime.connect({name: 'getStyles:' + JSON.stringify(msg)}); - // return true; - // } - // } catch (e) {} - // } - // } - function applyOnMessage(request) { if (request.method === 'ping') { return true;