Skip to content

Commit

Permalink
Added check to not launch popup window with no found link
Browse files Browse the repository at this point in the history
  • Loading branch information
emvaized committed Dec 9, 2024
1 parent 1b4babe commit 4ca6acf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ function onTrigger(e, type){
selectedText: window.getSelection().toString().trim(),
availLeft: window.screen.availLeft, type: type
}
if (type == 'drag' || type == 'shiftClick') {
let nodeName, link;

let nodeName, link;
if (type == 'drag' || type == 'shiftClick') {
/// Handle IMG wrapped in A
if (t.parentNode && t.parentNode.nodeName == 'A'){
if (configs.imageWithLinkPreferLink){
Expand All @@ -98,13 +98,15 @@ function onTrigger(e, type){
}

/// Handle IMG with source in sourceset
if (nodeName == 'IMG' && !link) {
if (nodeName == 'IMG' && !link && t.parentNode && t.parentNode.nodeName == 'PICTURE') {
const src = t.parentNode.querySelector('source');
if (src) link = src.getAttribute('srcset');
}

message['nodeName'] = nodeName;
message['link'] = link;
}
chrome.runtime.sendMessage(message)

if (link)
chrome.runtime.sendMessage(message)
}

0 comments on commit 4ca6acf

Please sign in to comment.