fdbfb23547
* parserlib: fast section extraction, tweaks and speedups
* csslint: "simple-not" rule
* csslint: enable and fix "selector-newline" rule
* simplify db: resolve with result
* simplify download()
* remove noCode param as it wastes more time/memory on copying
* styleManager: switch style<->data names to reflect their actual contents
* inline method bodies to avoid indirection and enable better autocomplete/hint/jump support in IDE
* upgrade getEventKeyName to handle mouse clicks
* don't trust location.href as it hides text fragment
* getAllKeys is implemented since Chrome48, FF44
* allow recoverable css errors + async'ify usercss.js
* openManage: unminimize windows
* remove the obsolete Chrome pre-65 workaround
* fix temporal dead zone in apply.js
* ff bug workaround for simple editor window
* consistent window scrolling in scrollToEditor and jumpToPos
* rework waitForSelector and collapsible <details>
* blank paint frame workaround for new Chrome
* extract stuff from edit.js and load on demand
* simplify regexpTester::isShown
* move MozDocMapper to sections-util.js
* extract fitSelectBox()
* initialize router earlier
* use helpPopup.close()
* fix autofocus in popups, follow-up to 5bb1b5ef
* clone objects in prefs.get() + cosmetics
* reuse getAll result for INC
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
// preventing reregistration if reinjected by tabs.executeScript for whatever reason, just in case
|
|
if (typeof window.oldCode !== 'string') {
|
|
window.oldCode = (document.querySelector('body > pre') || document.body).textContent;
|
|
chrome.runtime.onConnect.addListener(port => {
|
|
if (port.name !== 'downloadSelf') return;
|
|
port.onMessage.addListener(async ({id, force}) => {
|
|
const msg = {id};
|
|
try {
|
|
const code = await (await fetch(location.href, {mode: 'same-origin'})).text();
|
|
if (code !== window.oldCode || force) {
|
|
msg.code = window.oldCode = code;
|
|
}
|
|
} catch (error) {
|
|
msg.error = error.message || `${error}`;
|
|
}
|
|
port.postMessage(msg);
|
|
});
|
|
// FF keeps content scripts connected on navigation https://github.com/openstyles/stylus/issues/864
|
|
addEventListener('pagehide', () => port.disconnect(), {once: true});
|
|
});
|
|
}
|
|
|
|
// passing the result to tabs.executeScript
|
|
window.oldCode; // eslint-disable-line no-unused-expressions
|