-1

Say I had a piece of JavaScript that did something pretty simple, light DOM manipulation, perhaps. Is there a way I could add this to Chrome (or any browser) so that it'll run every time I hit a defined, public site that I don't own (e.g. stackoverflow.com)?

charleszardo
  • 179
  • 12
  • Does this answer your question? [Run my Javascript code on every page on my browser, similar to how a chrome extension would](https://stackoverflow.com/questions/60292446/run-my-javascript-code-on-every-page-on-my-browser-similar-to-how-a-chrome-exte) – starball Oct 18 '22 at 07:34

1 Answers1

0

A userscript can do this for you. You'll need a userscript manager like Tampermonkey.

For example, the following userscript will log hi every time I visit example.com:

// ==UserScript==
// @name             My Userscript
// @description      <Put something here>
// @include          /^https://example\.com/
// @grant            none
// ==/UserScript==

console.log('hi');

DOM manipulation and pretty much logic you could think of and implement is possible too.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320