Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
357a2bdfcc | |||
3eaa7ed822 | |||
056c164659 | |||
7b2d07e1f5 | |||
2d1a7eceb0 |
8
TODO.md
8
TODO.md
@ -3,14 +3,6 @@ TODO
|
|||||||
|
|
||||||
aka a lot
|
aka a lot
|
||||||
|
|
||||||
P1
|
|
||||||
===
|
|
||||||
|
|
||||||
Musts.
|
|
||||||
|
|
||||||
* packaging
|
|
||||||
* signing
|
|
||||||
|
|
||||||
P2
|
P2
|
||||||
===
|
===
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ export const MASK = new RecentList("mask", [
|
|||||||
"*name*.*ext*",
|
"*name*.*ext*",
|
||||||
"*num*_*name*.*ext*",
|
"*num*_*name*.*ext*",
|
||||||
"*url*-*name*.*ext*",
|
"*url*-*name*.*ext*",
|
||||||
"*name* (*text*).*ext*",
|
"downthemall/*y*-*m*/*name*.*ext*",
|
||||||
"*name* (*hh*-*mm*).*ext*"
|
"*name* (*text*).*ext*"
|
||||||
]);
|
]);
|
||||||
MASK.init().catch(console.error);
|
MASK.init().catch(console.error);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "DownThemAll!",
|
"name": "DownThemAll!",
|
||||||
"version": "4.0.1",
|
"version": "4.0.2",
|
||||||
|
|
||||||
"description": "__MSG_extensionDescription__",
|
"description": "__MSG_extensionDescription__",
|
||||||
"homepage_url": "https://downthemall.org/",
|
"homepage_url": "https://downthemall.org/",
|
||||||
|
@ -92,12 +92,13 @@ class Gatherer {
|
|||||||
this.schemes = new Set(options.schemes);
|
this.schemes = new Set(options.schemes);
|
||||||
this.transferable = options.transferable;
|
this.transferable = options.transferable;
|
||||||
this.collectLink = this.collectLink.bind(this);
|
this.collectLink = this.collectLink.bind(this);
|
||||||
this.collectImages = this.collectImages.bind(this);
|
this.collectImage = this.collectImage.bind(this);
|
||||||
this.collectMedia = this.collectMedia.bind(this);
|
this.collectMedia = this.collectMedia.bind(this);
|
||||||
Object.freeze(this);
|
Object.freeze(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
collectLink(a: HTMLAnchorElement) {
|
collectLink(a: HTMLAnchorElement) {
|
||||||
|
try {
|
||||||
const item = this.makeItem(a.href, a);
|
const item = this.makeItem(a.href, a);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return item;
|
return item;
|
||||||
@ -107,13 +108,21 @@ class Gatherer {
|
|||||||
item.description = extractDescription(a);
|
item.description = extractDescription(a);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error("oopsed link", ex.toString(), ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
*collectImagesInternal(img: HTMLImageElement) {
|
*collectImageInternal(img: HTMLImageElement) {
|
||||||
|
try {
|
||||||
const src = img.currentSrc || img.src;
|
const src = img.currentSrc || img.src;
|
||||||
const item = this.makeItem(src, img);
|
const item = this.makeItem(src, img);
|
||||||
|
if (item) {
|
||||||
item.fileName = "";
|
item.fileName = "";
|
||||||
item.description = item.title;
|
item.description = item.title;
|
||||||
yield item;
|
yield item;
|
||||||
|
}
|
||||||
|
|
||||||
const {srcset} = img;
|
const {srcset} = img;
|
||||||
if (!srcset) {
|
if (!srcset) {
|
||||||
@ -126,13 +135,19 @@ class Gatherer {
|
|||||||
for (const i of imgs) {
|
for (const i of imgs) {
|
||||||
const item = this.makeItem(i, img);
|
const item = this.makeItem(i, img);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
item.fileName = "";
|
||||||
|
item.description = item.title;
|
||||||
yield item;
|
yield item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error("oops image", ex.toString(), ex.stack, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
collectImages(img: HTMLImageElement) {
|
collectImage(img: HTMLImageElement) {
|
||||||
return [...this.collectImagesInternal(img)];
|
return [...this.collectImageInternal(img)];
|
||||||
}
|
}
|
||||||
|
|
||||||
collectMediaInternal(title: string | undefined | null, el: HTMLMediaElement) {
|
collectMediaInternal(title: string | undefined | null, el: HTMLMediaElement) {
|
||||||
@ -156,6 +171,7 @@ class Gatherer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
collectMedia(el: HTMLMediaElement) {
|
collectMedia(el: HTMLMediaElement) {
|
||||||
|
try {
|
||||||
const item = this.collectMediaInternal(el.getAttribute("title"), el);
|
const item = this.collectMediaInternal(el.getAttribute("title"), el);
|
||||||
const rv = item ? [item] : [];
|
const rv = item ? [item] : [];
|
||||||
const title: string | undefined = item && item.title ||
|
const title: string | undefined = item && item.title ||
|
||||||
@ -164,6 +180,11 @@ class Gatherer {
|
|||||||
map(this.collectMediaInternal.bind(this, title)));
|
map(this.collectMediaInternal.bind(this, title)));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.log("oopsed media", ex.toString(), ex);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
*findTexts() {
|
*findTexts() {
|
||||||
let doc = document;
|
let doc = document;
|
||||||
@ -207,9 +228,15 @@ class Gatherer {
|
|||||||
if (!this.textLinks) {
|
if (!this.textLinks) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
return Array.from(this.findTextLinks()).
|
return Array.from(this.findTextLinks()).
|
||||||
map(link => this.makeItem(link.href, link));
|
map(link => this.makeItem(link.href, link));
|
||||||
}
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error("oopsed textlinks", ex.toString(), ex);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
makeItem(surl: string, el: HTMLElement, title?: string | null): any {
|
makeItem(surl: string, el: HTMLElement, title?: string | null): any {
|
||||||
if (!(el as any).fake && this.selectionOnly &&
|
if (!(el as any).fake && this.selectionOnly &&
|
||||||
@ -276,7 +303,7 @@ function gather(msg: any, sender: any, callback: Function) {
|
|||||||
gatherer.collectTextLinks()),
|
gatherer.collectTextLinks()),
|
||||||
media: gatherer.makeUniqueItems(
|
media: gatherer.makeUniqueItems(
|
||||||
Array.from(document.querySelectorAll("img")).
|
Array.from(document.querySelectorAll("img")).
|
||||||
flatMap(gatherer.collectImages),
|
flatMap(gatherer.collectImage),
|
||||||
Array.from(document.querySelectorAll("video")).
|
Array.from(document.querySelectorAll("video")).
|
||||||
flatMap(gatherer.collectMedia),
|
flatMap(gatherer.collectMedia),
|
||||||
Array.from(document.querySelectorAll("audio")).
|
Array.from(document.querySelectorAll("audio")).
|
||||||
|
Reference in New Issue
Block a user