mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
Merge pull request #24 from minj/improve-link-detection
improve link detection in notify-link-clicks
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
window.addEventListener("click", notifyExtension);
|
||||
|
||||
function notifyExtension(e) {
|
||||
console.log("content script sending message");
|
||||
if (e.target.tagName != "A") {
|
||||
return;
|
||||
var target = e.target;
|
||||
while ((target.tagName != "A" || !target.href) && target.parentNode) {
|
||||
target = target.parentNode;
|
||||
}
|
||||
chrome.runtime.sendMessage({"url": e.target.href});
|
||||
if (target.tagName != "A")
|
||||
return;
|
||||
|
||||
console.log("content script sending message");
|
||||
chrome.runtime.sendMessage({"url": target.href});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
window.addEventListener("click", notifyExtension);
|
||||
|
||||
function notifyExtension(e) {
|
||||
if (e.target.tagName != "A") {
|
||||
return;
|
||||
var target = e.target;
|
||||
while ((target.tagName != "A" || !target.href) && target.parentNode) {
|
||||
target = target.parentNode;
|
||||
}
|
||||
if (target.tagName != "A")
|
||||
return;
|
||||
|
||||
console.log("content script sending message");
|
||||
chrome.runtime.sendMessage({"url": e.target.href});
|
||||
chrome.runtime.sendMessage({"url": target.href});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user