Fix: communicate -> runtimeSend

This commit is contained in:
eight 2017-09-12 18:58:39 +08:00
parent f3176de950
commit 97b4d91ec9

View File

@ -10,7 +10,7 @@ function install(style) {
reason: 'install', reason: 'install',
updateUrl: location.href updateUrl: location.href
}); });
return communicate(request) return runtimeSend(request)
.then(result => { .then(result => {
$$('.warning') $$('.warning')
.forEach(el => el.remove()); .forEach(el => el.remove());
@ -23,7 +23,7 @@ function install(style) {
}); });
} }
function communicate(request) { function runtimeSend(request) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chrome.runtime.sendMessage(request, result => { chrome.runtime.sendMessage(request, result => {
if (result.status === 'error') { if (result.status === 'error') {
@ -114,7 +114,7 @@ function initLiveReload(sourceLoader) {
let installed; let installed;
const watcher = sourceLoader.watch(source => { const watcher = sourceLoader.watch(source => {
$('.code').textContent = source; $('.code').textContent = source;
return communicate({ return runtimeSend({
method: 'saveUsercss', method: 'saveUsercss',
id: installed.id, id: installed.id,
source: source source: source
@ -230,7 +230,7 @@ function createSourceLoader() {
} }
function initUsercssInstall() { function initUsercssInstall() {
pendingResource = communicate({ pendingResource = runtimeSend({
method: 'injectContent', method: 'injectContent',
files: [ files: [
'/js/dom.js', '/js/dom.js',
@ -244,7 +244,7 @@ function initUsercssInstall() {
const sourceLoader = createSourceLoader(); const sourceLoader = createSourceLoader();
sourceLoader.load() sourceLoader.load()
.then(() => .then(() =>
communicate({ runtimeSend({
method: 'filterUsercss', method: 'filterUsercss',
source: sourceLoader.source(), source: sourceLoader.source(),
checkDup: true checkDup: true