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

View File

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

View File

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

View File

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