1 year ago

#360706

test-img

xtr33me

Any way to test for 404 errors at different domains from Google Chrome extension code?

My wife has over 12k Pinterest pins and there are many that resolve to 404 errors. I thought it would be simple to just create a chrome extension she could run that would get the pins, then I would test the URLs for 404 errors and then perform a delete.

Creating the plugin wasn't difficult but of all things, I am getting hung up on being able to determine whether the remote URL is a 404 due to CORS issues. Using fetch with a mode of no-cors does not error but it doesn't return me anything that I can use to determine whether the link is valid or not. I understand the purpose of CORS, but I'm just surprised that there isn't a way to tell from javascript whether or not a domain is valid.

I've seen some approaches where it was stated to use a proxy which I guess you append the headers with, however I thought I would see if there was any creative means of telling whether an endpoint is even existent or not. I'm really only interested in capturing the broken links so I can then go about deleting the pins programmatically. I was going to go about testing whether I could use an iframe to assign src to the url and see if I'm able to extract any more info that way, but figured I would post here to see if there are any other creative approaches. I also tried performing a fetch for favicon.ico, thinking it would get around CORS due to it being an image and not the full page, but this didn't work as well as I was hoping.

If you have any ideas, please let me know. Thanks!

javascript

cross-domain

same-origin-policy

0 Answers

Your Answer

Accepted video resources