hymbz / ComicReadScript

为漫画站增加双页阅读模式及优化使用体验。
https://comic-read.pages.dev/
GNU Affero General Public License v3.0
554 stars 26 forks source link

[Feature request]: Replace links endings with archive extension to ComicReadPWA links on kemono #130

Closed EnergoStalin closed 6 months ago

EnergoStalin commented 6 months ago

Something like this not sure where better to add it. Maybe it can be reused somewhere.

const supportedArchiveExtensions = ["zip", "rar"]

Array.from(document.querySelectorAll("a")).filter(e => supportedArchiveExtensions.includes(e.href.split(".").pop())).forEach(e => {
  e.textContent = e.textContent.replace("Download", "ComicReadPWA")
  e.removeAttribute("download")

  e.href = `https://comic-read.pages.dev/?url=${encodeURIComponent(e.href)}`
})

I have it already in separate userscript. But decided to share since it related.

hymbz commented 6 months ago

Good idea. However, apart from Kemono, I can't think of any other websites that could use it. And since kemono already has a read mode that can be directly activated on the webpage, there probably isn't a need to add this feature anymore, right?

EnergoStalin commented 6 months ago

Sometimes posts have archives attached. That feature intended to change their download links to comic-read.pages for opening them directly by its open archive from url feature.

EnergoStalin commented 6 months ago

Because from what i noticed some authors not post images directly and distribute it mostly in archives or cloud storages.

hymbz commented 6 months ago

So that's how it is, I understand now. I will include this feature in the next update. However, I don't like to directly modify the href, as it then becomes impossible to download the compressed file directly. I will add a new button next to the original one.

Also, I noticed that your previous code included e.target = "_blank", but it's not there now. Do you still need e.target = "_blank"?

EnergoStalin commented 6 months ago

Also, I noticed that your previous code included e.target = "_blank", but it's not there now. Do you still need e.target = "_blank"?

No. I think it was already resolved by your fix in #113.

EnergoStalin commented 6 months ago

Or wait it depends on what behaviour we want by left click. I left it in my script like posted in this thread cause if you want open in new tab you can always do middle click.

hymbz commented 6 months ago

Already updated.

EnergoStalin commented 6 months ago

Great thank you!