chrome.extension.sendMessage -> chrome.runtime.sendMessage
This commit is contained in:
parent
8f10fc291e
commit
d957cd1b3b
4
apply.js
4
apply.js
|
@ -19,7 +19,7 @@ function requestStyles() {
|
|||
bg.getStyles(request, applyStyles);
|
||||
}
|
||||
}
|
||||
chrome.extension.sendMessage(request, applyStyles);
|
||||
chrome.runtime.sendMessage(request, applyStyles);
|
||||
}
|
||||
|
||||
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
|
||||
|
@ -38,7 +38,7 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
|
|||
}
|
||||
case "styleAdded":
|
||||
if (request.style.enabled == "true") {
|
||||
chrome.extension.sendMessage({method: "getStyles", matchUrl: location.href, enabled: true, id: request.style.id, asHash: true}, applyStyles);
|
||||
chrome.runtime.sendMessage({method: "getStyles", matchUrl: location.href, enabled: true, id: request.style.id, asHash: true}, applyStyles);
|
||||
}
|
||||
break;
|
||||
case "styleApply":
|
||||
|
|
4
edit.js
4
edit.js
|
@ -1079,7 +1079,7 @@ function init() {
|
|||
tE("heading", "editStyleHeading", null, false);
|
||||
requestStyle();
|
||||
function requestStyle() {
|
||||
chrome.extension.sendMessage({method: "getStyles", id: params.id}, function callback(styles) {
|
||||
chrome.runtime.sendMessage({method: "getStyles", id: params.id}, function callback(styles) {
|
||||
if (!styles) { // Chrome is starting up and shows edit.html
|
||||
requestStyle();
|
||||
return;
|
||||
|
@ -1247,7 +1247,7 @@ function save() {
|
|||
enabled: enabled,
|
||||
sections: getSectionsHashes()
|
||||
};
|
||||
chrome.extension.sendMessage(request, saveComplete);
|
||||
chrome.runtime.sendMessage(request, saveComplete);
|
||||
}
|
||||
|
||||
function getSectionsHashes() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
healthCheck();
|
||||
|
||||
function healthCheck() {
|
||||
chrome.extension.sendMessage({method: "healthCheck"}, function(ok) {
|
||||
chrome.runtime.sendMessage({method: "healthCheck"}, function(ok) {
|
||||
if (ok === undefined) { // Chrome is starting up
|
||||
healthCheck();
|
||||
} else if (!ok && confirm(t("dbError"))) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
chrome.extension.sendMessage({method: "getStyles", url: getMeta("stylish-id-url") || location.href}, function(response) {
|
||||
chrome.runtime.sendMessage({method: "getStyles", url: getMeta("stylish-id-url") || location.href}, function(response) {
|
||||
if (response.length == 0) {
|
||||
sendEvent("styleCanBeInstalledChrome");
|
||||
} else {
|
||||
|
@ -76,7 +76,7 @@ document.addEventListener("stylishInstallChrome", function() {
|
|||
// check for old style json
|
||||
var json = JSON.parse(code);
|
||||
json.method = "saveStyle";
|
||||
chrome.extension.sendMessage(json, function(response) {
|
||||
chrome.runtime.sendMessage(json, function(response) {
|
||||
sendEvent("styleInstalledChrome");
|
||||
});
|
||||
});
|
||||
|
@ -86,14 +86,14 @@ document.addEventListener("stylishInstallChrome", function() {
|
|||
}, false);
|
||||
|
||||
document.addEventListener("stylishUpdateChrome", function() {
|
||||
chrome.extension.sendMessage({method: "getStyles", url: getMeta("stylish-id-url") || location.href}, function(response) {
|
||||
chrome.runtime.sendMessage({method: "getStyles", url: getMeta("stylish-id-url") || location.href}, function(response) {
|
||||
var style = response[0];
|
||||
if (confirm(chrome.i18n.getMessage('styleUpdate', [style.name]))) {
|
||||
getResource(getMeta("stylish-code-chrome"), function(code) {
|
||||
var json = JSON.parse(code);
|
||||
json.method = "saveStyle";
|
||||
json.id = style.id;
|
||||
chrome.extension.sendMessage(json, function() {
|
||||
chrome.runtime.sendMessage(json, function() {
|
||||
sendEvent("styleInstalledChrome");
|
||||
});
|
||||
});
|
||||
|
|
12
manage.js
12
manage.js
|
@ -5,11 +5,11 @@ var appliesToExtraTemplate = document.createElement("span");
|
|||
appliesToExtraTemplate.className = "applies-to-extra";
|
||||
appliesToExtraTemplate.innerHTML = " " + t('appliesDisplayTruncatedSuffix');
|
||||
|
||||
chrome.extension.sendMessage({method: "getStyles"}, showStyles);
|
||||
chrome.runtime.sendMessage({method: "getStyles"}, showStyles);
|
||||
|
||||
function showStyles(styles) {
|
||||
if (!styles) { // Chrome is starting up
|
||||
chrome.extension.sendMessage({method: "getStyles"}, showStyles);
|
||||
chrome.runtime.sendMessage({method: "getStyles"}, showStyles);
|
||||
return;
|
||||
}
|
||||
if (!installed) {
|
||||
|
@ -114,7 +114,7 @@ function createStyleElement(style) {
|
|||
options.url = url;
|
||||
chrome.windows.create(options);
|
||||
} else {
|
||||
chrome.extension.sendMessage({
|
||||
chrome.runtime.sendMessage({
|
||||
method: "openURL",
|
||||
url: url,
|
||||
active: openForegroundTab
|
||||
|
@ -251,7 +251,7 @@ function checkUpdate(element, callback) {
|
|||
var originalMd5 = element.getAttribute("style-original-md5");
|
||||
|
||||
function handleSuccess(forceUpdate, serverJson) {
|
||||
chrome.extension.sendMessage({method: "getStyles", id: id}, function(styles) {
|
||||
chrome.runtime.sendMessage({method: "getStyles", id: id}, function(styles) {
|
||||
var style = styles[0];
|
||||
var needsUpdate = false;
|
||||
if (!forceUpdate && codeIsEqual(style.sections, serverJson.sections)) {
|
||||
|
@ -362,7 +362,7 @@ function doUpdate(event) {
|
|||
|
||||
// updating the UI will be handled by the general update listener
|
||||
lastUpdatedStyleId = updatedCode.id;
|
||||
chrome.extension.sendMessage(updatedCode);
|
||||
chrome.runtime.sendMessage(updatedCode);
|
||||
}
|
||||
|
||||
function codeIsEqual(a, b) {
|
||||
|
@ -430,7 +430,7 @@ function searchStyles(immediately) {
|
|||
searchStyles.timeout = setTimeout(doSearch, 100);
|
||||
}
|
||||
function doSearch() {
|
||||
chrome.extension.sendMessage({method: "getStyles"}, function(styles) {
|
||||
chrome.runtime.sendMessage({method: "getStyles"}, function(styles) {
|
||||
styles.forEach(function(style) {
|
||||
var el = document.querySelector("[style-id='" + style.id + "']");
|
||||
if (el) {
|
||||
|
|
|
@ -9,7 +9,7 @@ function notifyAllTabs(request) {
|
|||
});
|
||||
// notify all open popups
|
||||
var reqPopup = shallowMerge({}, request, {method: "updatePopup", reason: request.method});
|
||||
chrome.extension.sendMessage(reqPopup);
|
||||
chrome.runtime.sendMessage(reqPopup);
|
||||
}
|
||||
|
||||
function updateIcon(tab, styles) {
|
||||
|
@ -39,7 +39,7 @@ function updateIcon(tab, styles) {
|
|||
if (typeof getStyles != "undefined") {
|
||||
getStyles({matchUrl: url, enabled: true}, stylesReceived);
|
||||
} else {
|
||||
chrome.extension.sendMessage({method: "getStyles", matchUrl: url, enabled: true}, stylesReceived);
|
||||
chrome.runtime.sendMessage({method: "getStyles", matchUrl: url, enabled: true}, stylesReceived);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
4
popup.js
4
popup.js
|
@ -17,7 +17,7 @@ function updatePopUp(url) {
|
|||
return;
|
||||
}
|
||||
|
||||
chrome.extension.sendMessage({method: "getStyles", matchUrl: url}, showStyles);
|
||||
chrome.runtime.sendMessage({method: "getStyles", matchUrl: url}, showStyles);
|
||||
document.querySelector("#find-styles a").href = "https://userstyles.org/styles/browse/all/" + encodeURIComponent("file" === urlWillWork[1] ? "file:" : url);
|
||||
|
||||
// Write new style links
|
||||
|
@ -159,7 +159,7 @@ function openLinkInTabOrWindow(event) {
|
|||
|
||||
function openLink(event) {
|
||||
event.preventDefault();
|
||||
chrome.extension.sendMessage({method: "openURL", url: event.target.href});
|
||||
chrome.runtime.sendMessage({method: "openURL", url: event.target.href});
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ function enableStyle(id, enabled) {
|
|||
db.transaction(function (t) {
|
||||
t.executeSql("UPDATE styles SET enabled = ? WHERE id = ?;", [enabled, id]);
|
||||
}, reportError, function() {
|
||||
chrome.extension.sendMessage({method: "styleChanged"});
|
||||
chrome.extension.sendMessage({method: "getStyles", id: id}, function(styles) {
|
||||
chrome.runtime.sendMessage({method: "styleChanged"});
|
||||
chrome.runtime.sendMessage({method: "getStyles", id: id}, function(styles) {
|
||||
handleUpdate(styles[0]);
|
||||
notifyAllTabs({method: "styleUpdated", style: styles[0]});
|
||||
});
|
||||
|
@ -93,7 +93,7 @@ function deleteStyle(id) {
|
|||
t.executeSql('DELETE FROM sections WHERE style_id = ?;', [id]);
|
||||
t.executeSql("DELETE FROM styles WHERE id = ?;", [id]);
|
||||
}, reportError, function() {
|
||||
chrome.extension.sendMessage({method: "styleChanged"});
|
||||
chrome.runtime.sendMessage({method: "styleChanged"});
|
||||
handleDelete(id);
|
||||
notifyAllTabs({method: "styleDeleted", id: id});
|
||||
});
|
||||
|
@ -232,7 +232,7 @@ var prefs = chrome.extension.getBackgroundPage().prefs || new function Prefs() {
|
|||
Prefs.prototype.broadcast = function(key, value, options) {
|
||||
var message = {method: "prefChanged", prefName: key, value: value};
|
||||
notifyAllTabs(message);
|
||||
chrome.extension.sendMessage(message);
|
||||
chrome.runtime.sendMessage(message);
|
||||
if (key == "disableAll") {
|
||||
notifyAllTabs({method: "styleDisableAll", disableAll: value});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user