Index: ext/background.js |
diff --git a/ext/background.js b/ext/background.js |
index 88665eab3e936b3225131b706751a01eee9014d8..cf9337ab5b2169c702ec9f5293788de2cdded301 100644 |
--- a/ext/background.js |
+++ b/ext/background.js |
@@ -15,17 +15,18 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-(function(global) |
+"use strict"; |
+ |
{ |
- if (!global.ext) |
- global.ext = {}; |
+ if (typeof ext == "undefined") |
+ window.ext = {}; |
- window.addEventListener("load", function() |
+ window.addEventListener("load", () => |
{ |
parent.postMessage({ |
type: "backgroundPageLoaded" |
}, "*"); |
- }, false) |
+ }, false); |
function PageMap() |
{ |
@@ -33,27 +34,27 @@ |
this._values = []; |
} |
PageMap.prototype = { |
- keys: function() |
+ keys() |
{ |
- return this._keys.map(function(source) |
+ return this._keys.map(source => |
{ |
- return new global.ext.Page(source); |
+ return new window.ext.Page(source); |
}); |
}, |
- get: function(page) |
+ get(page) |
{ |
return this._values[this._keys.indexOf(page._source)]; |
}, |
- set: function(page, value) |
+ set(page, value) |
{ |
- var index = this._keys.indexOf(page._source); |
+ let index = this._keys.indexOf(page._source); |
if (index < 0) |
{ |
index = this._keys.push(page._source) - 1; |
- var callback = function() |
+ let callback = function() |
{ |
page._source.removeEventListener("unload", callback, false); |
this.delete(page); |
@@ -63,9 +64,9 @@ |
this._values[index] = value; |
}, |
- delete: function(page) |
+ delete(page) |
{ |
- var index = this._keys.indexOf(page._source); |
+ let index = this._keys.indexOf(page._source); |
if (index >= 0) |
{ |
this._keys.splice(index, 1); |
@@ -74,9 +75,9 @@ |
} |
}; |
- global.ext.PageMap = PageMap; |
+ window.ext.PageMap = PageMap; |
- global.ext.showOptions = function(callback) |
+ window.ext.showOptions = function(callback) |
{ |
if (top.location.href.indexOf("new-options.html") == -1) |
window.open("new-options.html", "_blank"); |
@@ -85,11 +86,11 @@ |
callback(); |
}; |
- global.ext.devtools = { |
+ window.ext.devtools = { |
onCreated: { |
- addListener: function(listener) |
+ addListener(listener) |
{ |
- window.addEventListener("message", function(event) |
+ window.addEventListener("message", event => |
{ |
if (event.data.type == "devtools") |
listener(new ext.Page(event.source)); |
@@ -97,4 +98,4 @@ |
} |
} |
}; |
-})(this); |
+} |