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: Created Feb. 20, 2017, 10: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
« background.js ('K') | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »
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..0c216d57000a2c932d6c65cf7fd6ba160b178b57 100644
--- a/ext/content.js
+++ b/ext/content.js
@@ -15,58 +15,63 @@
* 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 = {};
- 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++)
+ {
+ for (let i = 0; i < queue.length; i++)
backgroundFrame.contentWindow.postMessage(queue[i], "*");
+ }
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 +81,4 @@
}
}
};
-})(this);
+}
« background.js ('K') | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld