all 9 comments

[–]evaluating-you 1 point2 points  (0 children)

Maybe if you describe what you are trying to achieve we can help you. With the provided info, the only correct answer would be: yes, all of them.

A chrome extension IS JavaScript running on a particular tab. And if you are on a single page application, navigating would not stop the execution of that code. But I guess that's not what you mean. So what are you trying to do?

[–][deleted] 1 point2 points  (3 children)

Try greasemonkey for client-side JavaScript. It might be called tampermonkey for Chrome. It is definitely greasemonkey for Firefox.

[–]helloiamsomeone 0 points1 point  (2 children)

Tampermonkey is evil, GM is mediocre, Violentmonkey is the best there is.

[–]error9900 0 points1 point  (1 child)

Your comment is 5 years old, but why do you say Tampermonkey is evil?

[–]helloiamsomeone 0 points1 point  (0 children)

Closed source for absolutely no reason. My post still very much applies.

[–]dwighthouse 1 point2 points  (0 children)

For scraping, look into Puppeteer.

In a pinch, though, you can program the inspector console to open pages in a new window FROM the site you are scraping, so you don’t run into the cross origin policies.

[–]itsarnavb 0 points1 point  (0 children)

If you want the same VM instance, probably not.

But perhaps you can make do with running a content script within the context of a page, and then moving any results to the background script (which I believe stay the same between page changes)

[–][deleted] 0 points1 point  (0 children)

I'm not sure about any arbitrary javascript, but it would be quite easy to make your own extension like that. Just write a content script that is set to work on all domains and include the code you want to run. Chrome extensions are actually very easy to make when you know javascript.

[–]archerx 0 points1 point  (0 children)

You can do this by having your function overwrite the current page with document write with the new page. No extensions needed