Index: background.js |
diff --git a/background.js b/background.js |
index 355905b59296b91571fc4739253be3b1f6dd8be7..99b462f9a992351f7c225d40303723d928251646 100644 |
--- a/background.js |
+++ b/background.js |
@@ -119,7 +119,7 @@ var contextMenuItem = { |
contexts: ["image", "video", "audio"], |
onclick: function(page) |
{ |
- page.sendMessage({type: "clickhide-new-filter"}); |
+ page.sendMessage({type: "blockelement-context-menu-clicked"}); |
} |
}; |
@@ -283,6 +283,40 @@ ext.onMessage.addListener(function (msg, sender, sendResponse) |
{ |
switch (msg.type) |
{ |
+ case "blockelement-open-popup": |
+ var url = ext.getURL("block.html") + "?targetPageId=" + sender.page._id + |
Sebastian Noack
2016/02/10 12:26:56
Alternatively, you could send this data to the pop
kzar
2016/02/10 14:20:16
I think this would work for Chrome but not Safari.
Sebastian Noack
2016/02/10 14:43:24
As I said, we already do so for the options page.
Sebastian Noack
2016/02/12 17:00:00
So what's about that comment?
kzar
2016/02/13 14:18:12
Well I tried it and it didn't work for me.
Lookin
Sebastian Noack
2016/02/15 14:50:17
Well, when opening the options page, we look for a
|
+ "&filters=" + encodeURIComponent(JSON.stringify(msg.filters)); |
+ ext.windows.create({ |
+ url: url, |
+ left: 50, |
+ top: 50, |
+ width: 420, |
+ height: 200, |
+ focused: true, |
+ type: "popup" |
+ }, |
+ function (popupPage) { |
+ var popupPageId = popupPage._id; |
+ function onRemoved(removedPageId) |
+ { |
+ if (popupPageId == removedPageId) |
+ { |
+ sender.page.sendMessage({ |
+ type: "blockelement-popup-closed", |
+ popupId: popupPageId |
+ }); |
+ ext.pages.onRemoved.removeListener(onRemoved); |
+ } |
+ } |
+ ext.pages.onRemoved.addListener(onRemoved); |
+ |
+ sender.page.sendMessage({ |
+ type: "blockelement-popup-opened", |
+ popupId: popupPageId |
+ }); |
+ }); |
+ return true; |
Sebastian Noack
2016/02/10 12:26:56
By returning true but never calling sendResponse()
kzar
2016/02/10 14:20:16
Done.
|
+ break; |
case "get-selectors": |
var selectors = []; |
var trace = devtools && devtools.hasPanel(sender.page); |
@@ -402,15 +436,21 @@ ext.onMessage.addListener(function (msg, sender, sendResponse) |
); |
break; |
case "forward": |
- if (sender.page) |
+ var targetPage; |
+ if (msg.targetPageId) |
+ targetPage = ext._getPage(msg.targetPageId); |
Sebastian Noack
2016/02/10 12:26:56
I guess it's time, to remove the prefix from ext._
kzar
2016/02/10 14:20:16
Done.
|
+ else |
+ targetPage = sender.page; |
+ |
+ if (targetPage) |
{ |
if (msg.expectsResponse) |
{ |
- sender.page.sendMessage(msg.payload, sendResponse); |
+ targetPage.sendMessage(msg.payload, sendResponse); |
return true; |
} |
- sender.page.sendMessage(msg.payload); |
+ targetPage.sendMessage(msg.payload); |
} |
break; |
} |
@@ -419,7 +459,7 @@ ext.onMessage.addListener(function (msg, sender, sendResponse) |
// update icon when page changes location |
ext.pages.onLoading.addListener(function(page) |
{ |
- page.sendMessage({type: "clickhide-deactivate"}); |
+ page.sendMessage({type: "blockelement-finished"}); |
refreshIconAndContextMenu(page); |
showNextNotificationForUrl(page.url); |
}); |