From 81f3e69574bee2eeffd9d0a5bbb0811f49436520 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 14 Oct 2018 18:50:54 +0800 Subject: [PATCH] Change: getStylesInfoByUrl -> getStylesByUrl --- background/background.js | 2 +- background/search-db.js | 2 +- background/style-manager.js | 6 +++--- popup/popup.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/background/background.js b/background/background.js index 25944231..b6c090dd 100644 --- a/background/background.js +++ b/background/background.js @@ -15,7 +15,7 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, { getAllStyles: styleManager.getAllStyles, // used by importer getSectionsByUrl: styleManager.getSectionsByUrl, getStyle: styleManager.get, - getStylesInfoByUrl: styleManager.getStylesInfoByUrl, + getStylesByUrl: styleManager.getStylesByUrl, importStyle: styleManager.importStyle, installStyle: styleManager.installStyle, styleExists: styleManager.styleExists, diff --git a/background/search-db.js b/background/search-db.js index b9c14678..78a721f9 100644 --- a/background/search-db.js +++ b/background/search-db.js @@ -25,7 +25,7 @@ if (/^url:/i.test(query)) { matchUrl = query.slice(query.indexOf(':') + 1).trim(); if (matchUrl) { - return styleManager.getStylesInfoByUrl(matchUrl) + return styleManager.getStylesByUrl(matchUrl, true) .then(results => results.map(r => r.data.id)); } } diff --git a/background/style-manager.js b/background/style-manager.js index 74c2697c..f58ef822 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -58,7 +58,7 @@ const styleManager = (() => { toggleStyle, setStyleExclusions, getAllStyles, // used by import-export - getStylesInfoByUrl, // used by popup + getStylesByUrl, // used by popup styleExists, }); @@ -277,7 +277,7 @@ const styleManager = (() => { } // get styles matching a URL, including sloppy regexps and excluded items. - function getStylesInfoByUrl(url) { + function getStylesByUrl(url, noCode = false) { // FIXME: do we want to cache this? Who would like to open popup rapidly // or search the DB with the same URL? const result = []; @@ -308,7 +308,7 @@ const styleManager = (() => { } if (sectionMatched) { result.push({ - data: getStyleWithNoCode(style.data), + data: noCode ? getStyleWithNoCode(style.data) : style.data, excluded, sloppy }); diff --git a/popup/popup.js b/popup/popup.js index 032c3691..7cf59b58 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -25,7 +25,7 @@ getActiveTab() ) .then(url => Promise.all([ (tabURL = URLS.supported(url) ? url : '') && - API.getStylesInfoByUrl(tabURL), + API.getStylesByUrl(tabURL, true), onDOMready().then(initPopup), ])) .then(([results]) => {