Index: ext/popup.js |
=================================================================== |
--- a/ext/popup.js |
+++ b/ext/popup.js |
@@ -2,29 +2,55 @@ |
(function() |
{ |
if (typeof chrome == "undefined" || typeof chrome.extension == "undefined") |
window.chrome = browser; |
const backgroundPage = chrome.extension.getBackgroundPage(); |
window.ext = Object.create(backgroundPage.ext); |
- window.ext.closePopup = () => |
- { |
- window.close(); |
- }; |
- |
// Calling i18n.getMessage from the background page causes Edge to throw an |
// exception. |
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12793975/ |
window.ext.i18n = chrome.i18n; |
// We have to override ext.backgroundPage, because in order |
// to send messages the local "chrome" namespace must be used. |
window.ext.backgroundPage = { |
sendMessage: chrome.runtime.sendMessage, |
getWindow() |
{ |
return backgroundPage; |
} |
}; |
+ |
+ window.ext.closePopup = () => |
+ { |
+ window.close(); |
+ }; |
Sebastian Noack
2017/09/13 02:49:39
While moving this function around anyway, how abou
Manish Jethani
2017/09/18 02:25:50
OK, this should happen naturally now after changes
|
+ |
+ window.ext.prefs = { |
+ get(key, callback) |
+ { |
+ chrome.runtime.sendMessage({type: "prefs.get", key}, callback); |
+ }, |
+ toggle(key, callback) |
+ { |
+ chrome.runtime.sendMessage({type: "prefs.toggle", key}, callback); |
+ } |
+ }; |
Sebastian Noack
2017/09/13 02:49:39
IMO, this doesn't belong into ext. Prefs are part
Manish Jethani
2017/09/18 02:25:50
I've moved it into popup.js now.
|
+ |
+ window.ext.createPageObject = tab => |
+ { |
+ if (!tab) |
+ return null; |
+ |
+ // Create a lightweight page object that resembles ext.Page, but with only |
+ // an id and an optional url property. |
+ let page = {id: tab.id}; |
+ |
+ if (tab.url) |
+ page.url = new URL(tab.url); |
+ |
+ return page; |
+ }; |
}()); |