Minor fixes

This commit is contained in:
eight 2018-10-07 21:28:51 +08:00
parent 5b3b4e680f
commit c5d41529d9
4 changed files with 17 additions and 8 deletions

View File

@ -4,7 +4,7 @@ global handleCssTransitionBug detectSloppyRegexps
global openEditor global openEditor
global styleViaAPI global styleViaAPI
global loadScript global loadScript
global usercss styleManager db msg global usercss styleManager db msg navigatorUtil
*/ */
'use strict'; 'use strict';
@ -140,7 +140,12 @@ prefs.subscribe(['iconset'], () =>
styles: {}, styles: {},
})); }));
chrome.navigator. navigatorUtil.onUrlChange(({url, tabId, frameId}) => {
if (frameId === 0) {
tabIcons.delete(tabId);
updateIcon({tab: {id: tabId, url}});
}
});
// ************************************************************************* // *************************************************************************
chrome.runtime.onInstalled.addListener(({reason}) => { chrome.runtime.onInstalled.addListener(({reason}) => {

View File

@ -1,10 +1,10 @@
/* global promisify */
'use strict'; 'use strict';
const navigatorUtil = (() => { const navigatorUtil = (() => {
const handler = { const handler = {
urlChange: null urlChange: null
}; };
let listeners;
const tabGet = promisify(chrome.tabs.get.bind(chrome.tabs)); const tabGet = promisify(chrome.tabs.get.bind(chrome.tabs));
return extendNative({onUrlChange}); return extendNative({onUrlChange});
@ -21,15 +21,18 @@ const navigatorUtil = (() => {
chrome.webNavigation.onCommitted.addListener(data => chrome.webNavigation.onCommitted.addListener(data =>
fixNTPUrl(data) fixNTPUrl(data)
.then(() => executeCallbacks(handler.urlChange, data, 'committed')); .then(() => executeCallbacks(handler.urlChange, data, 'committed'))
);
chrome.webNavigation.onHistoryStateUpdated.addListener(data => chrome.webNavigation.onHistoryStateUpdated.addListener(data =>
fixNTPUrl(data) fixNTPUrl(data)
.then(() => executeCallbacks(handler.urlChange, data, 'historyStateUpdated')); .then(() => executeCallbacks(handler.urlChange, data, 'historyStateUpdated'))
);
chrome.webNavigation.onReferenceFragmentUpdated.addListener(data => chrome.webNavigation.onReferenceFragmentUpdated.addListener(data =>
fixNTPUrl(data) fixNTPUrl(data)
.then(() => executeCallbacks(handler.urlChange, data, 'referenceFragmentUpdated')); .then(() => executeCallbacks(handler.urlChange, data, 'referenceFragmentUpdated'))
);
} }
function fixNTPUrl(data) { function fixNTPUrl(data) {

View File

@ -1,4 +1,4 @@
/* global getStyles API_METHODS */ /* global getStyles API_METHODS styleManager */
'use strict'; 'use strict';
API_METHODS.styleViaAPI = !CHROME && (() => { API_METHODS.styleViaAPI = !CHROME && (() => {
@ -45,6 +45,7 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
return styleManager.getSectionsByUrl(url, filter).then(sections => { return styleManager.getSectionsByUrl(url, filter).then(sections => {
const tasks = []; const tasks = [];
for (const section of Object.values(sections)) { for (const section of Object.values(sections)) {
const styleId = section.id;
const code = section.code; const code = section.code;
if (!code) { if (!code) {
delete frameStyles[styleId]; delete frameStyles[styleId];

View File

@ -2,7 +2,7 @@
global getStyles saveStyle styleSectionsEqual global getStyles saveStyle styleSectionsEqual
global calcStyleDigest cachedStyles getStyleWithNoCode global calcStyleDigest cachedStyles getStyleWithNoCode
global usercss semverCompare global usercss semverCompare
global API_METHODS global API_METHODS styleManager
*/ */
'use strict'; 'use strict';