-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
got constant redefinition on re-runs
- Loading branch information
Showing
3 changed files
with
61 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,61 @@ | ||
const domains = [ | ||
"imgur.com", | ||
"i.imgur.com", | ||
"twimg.com", | ||
"cdninstagram.com", | ||
"gfycat.com", | ||
"redgifs.com", | ||
"jiggie.fun", | ||
]; | ||
|
||
const fileExtensions = [ | ||
"jpg", | ||
"jpeg", | ||
"gif", | ||
"png", | ||
"bmp", | ||
"webm", | ||
"mp4", | ||
]; | ||
|
||
const exclusions = [ | ||
"xpi", | ||
"m3u8", | ||
] | ||
|
||
function startsWithHttp(url) { | ||
return url.startsWith("http"); | ||
} | ||
|
||
function isExcluded(url) { | ||
return exclusions.some((exclusion) => url.endsWith(exclusion)); | ||
} | ||
|
||
function hasMatchingDomain(url) { | ||
return domains.some((domain) => url.includes(domain)); | ||
} | ||
|
||
function hasMatchingExtension(url) { | ||
return fileExtensions.some((extension) => url.endsWith(extension)); | ||
} | ||
|
||
var images_to_check = new Array(); | ||
var links = document.getElementsByTagNameNS("*", "a"); | ||
|
||
if (links && links.length) { | ||
for (let link of links) { | ||
const url = link.href; | ||
if (startsWithHttp(url) && !isExcluded(url)) { | ||
if (hasMatchingDomain(url) || hasMatchingExtension(url)) { | ||
if (!images_to_check.includes(url)) { | ||
images_to_check.push(url); | ||
(function () { | ||
const domains = [ | ||
"imgur.com", | ||
"i.imgur.com", | ||
"twimg.com", | ||
"cdninstagram.com", | ||
"gfycat.com", | ||
"redgifs.com", | ||
"jiggie.fun", | ||
]; | ||
|
||
const fileExtensions = [ | ||
"jpg", | ||
"jpeg", | ||
"gif", | ||
"png", | ||
"bmp", | ||
"webm", | ||
"mp4", | ||
]; | ||
|
||
const exclusions = [ | ||
"xpi", | ||
"m3u8", | ||
] | ||
|
||
function startsWithHttp(url) { | ||
return url.startsWith("http"); | ||
} | ||
|
||
function isExcluded(url) { | ||
return exclusions.some((exclusion) => url.endsWith(exclusion)); | ||
} | ||
|
||
function hasMatchingDomain(url) { | ||
return domains.some((domain) => url.includes(domain)); | ||
} | ||
|
||
function hasMatchingExtension(url) { | ||
return fileExtensions.some((extension) => url.endsWith(extension)); | ||
} | ||
|
||
const images_to_check = []; | ||
const links = document.getElementsByTagNameNS("*", "a"); | ||
|
||
if (links && links.length) { | ||
for (let link of links) { | ||
const url = link.href; | ||
if (startsWithHttp(url) && !isExcluded(url)) { | ||
if (hasMatchingDomain(url) || hasMatchingExtension(url)) { | ||
if (!images_to_check.includes(url)) { | ||
images_to_check.push(url); | ||
} | ||
} | ||
} | ||
} | ||
browser.runtime.sendMessage(images_to_check); | ||
} else { | ||
alert("Cant access links in document!", 1); | ||
} | ||
browser.runtime.sendMessage(images_to_check); | ||
} else { | ||
alert("Cant access links in document!", 1); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "imagetabs", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"manifest_version": 2, | ||
"permissions": [ | ||
"tabs", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters