Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/content.js

Issue 29375899: Issue 4871 - Start using ESLint for adblockplusui (Closed)
Patch Set: Fix imports in antiadblockInit.js Created March 14, 2017, 9:01 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ext/common.js ('k') | ext/devtools.js » ('j') | lib/antiadblockInit.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/content.js
diff --git a/ext/content.js b/ext/content.js
index 3b5200b4e8d5b073269f382834d3a26714a96946..96538882301d2d3eacb841233a03345bb98c4ae3 100644
--- a/ext/content.js
+++ b/ext/content.js
@@ -15,58 +15,64 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-(function(global)
+"use strict";
+
+(function()
{
- if (!global.ext)
- global.ext = {};
+ if (typeof ext == "undefined")
+ window.ext = {};
- var backgroundFrame = document.createElement("iframe");
- backgroundFrame.setAttribute("src", "background.html" + window.location.search);
+ let backgroundFrame = document.createElement("iframe");
+ backgroundFrame.setAttribute("src",
+ "background.html" + window.location.search);
backgroundFrame.style.display = "none";
- window.addEventListener("DOMContentLoaded", function()
+ window.addEventListener("DOMContentLoaded", () =>
{
document.body.appendChild(backgroundFrame);
}, false);
- var messageQueue = [];
- var maxMessageId = -1;
- var loadHandler = function(event)
+ let messageQueue = [];
+ let maxMessageId = -1;
+ let loadHandler = (event) =>
{
if (event.data.type == "backgroundPageLoaded")
{
- var queue = messageQueue;
+ let queue = messageQueue;
messageQueue = null;
if (queue)
- for (var i = 0; i < queue.length; i++)
- backgroundFrame.contentWindow.postMessage(queue[i], "*");
+ {
+ for (let message of queue)
+ backgroundFrame.contentWindow.postMessage(message, "*");
+ }
window.removeEventListener("message", loadHandler, false);
}
- }
+ };
window.addEventListener("message", loadHandler, false);
- global.ext.backgroundPage = {
- _sendRawMessage: function(message)
+ ext.backgroundPage = {
+ _sendRawMessage(message)
{
if (messageQueue)
messageQueue.push(message);
else
backgroundFrame.contentWindow.postMessage(message, "*");
},
- sendMessage: function(message, responseCallback)
+ sendMessage(message, responseCallback)
{
- var messageId = ++maxMessageId;
+ let messageId = ++maxMessageId;
this._sendRawMessage({
type: "message",
- messageId: messageId,
+ messageId,
payload: message
});
if (responseCallback)
{
- var callbackWrapper = function(event)
+ let callbackWrapper = function(event)
{
- if (event.data.type == "response" && event.data.messageId == messageId)
+ if (event.data.type == "response" &&
+ event.data.messageId == messageId)
{
window.removeEventListener("message", callbackWrapper, false);
responseCallback(event.data.payload);
@@ -76,4 +82,4 @@
}
}
};
-})(this);
+}());
« no previous file with comments | « ext/common.js ('k') | ext/devtools.js » ('j') | lib/antiadblockInit.js » ('J')

Powered by Google App Engine
This is Rietveld