gildas-lormeau / SingleFile

Web Extension for saving a faithful copy of a complete web page in a single HTML file
GNU Affero General Public License v3.0
15.67k stars 1.02k forks source link

Anti-theft chain image save failure #1563

Open wjsw1781 opened 2 months ago

wjsw1781 commented 2 months ago

Describe the bug

i find the website save is ok ,but the img can not save,because the web open the Anti-theft rule, i know you get the img binary in background.js ,it will be error, could you use fetch in contentjs ? it will work! the url is https://weibo.com/1699432410/OwmaceM4N image image image

you see,it is 403! but if you run fetch() in contentjs context,it will be fine! image

the reason is reffer can not be set in popup,backgroud, slider,or other context, but contentjs can auto use the reffer in header,then bypass the rule!

wjsw1781 commented 2 months ago

you can mv the img2base64 from backgroud to contentjs or mv as much logic as possible from backgroud to contentjs! it is big job, so the dicision is on you! i want to say 存储一个页面资源的过程html css font img,直觉上就应该在contenjs,而不是在backgroundjs中! 遍历dom, hook iframe ,download img ,都应当放在contentjs中运行 background只关注事件!

gildas-lormeau commented 1 month ago

I cannot reproduce a successful fetch of the resource you mentioned in Chrome with the Dev Tools. See below. Note however that what you described is already implemented in SingleFile and works fine in Firefox.

image
wjsw1781 commented 1 month ago

Do you mean the firefox version of SingleFile? Can you give me an address?

wjsw1781 commented 1 month ago

i find it is ok in firefox! why? if it in edge or chrome ,it could not save the anti-img! could you give me a issue about it ? i want to study it ,thank you !!!!

企业微信截图_17266464933592 企业微信截图_17266465114547
wjsw1781 commented 1 month ago

i guess someone have talked about it , but i can not find those talkings, i am chinese , i could not search it good enough. and i really want to know how firefox can bypass the rule of anti-img! does it use fetch in context of contentjs? or use other way? i really want to know !

gildas-lormeau commented 1 month ago

It's painful to debug but it looks like it's related to the cache.