I recently had to do many forced and unwanted surveys. While I obviously solved this issue programmatically, I wished the pages I worked on had jQuery injected to easily manipulate the DOM. This is neither a new or novel idea, but the following problems forced me to code a new extension:
- The bookmark solution (an example) violates Chrome's cross-policy exclusion of scripts and will refuse to load.
- Current Chrome Extensions had several problems. They either:
- Were hard-coded to a specific jQuery version.
- Were hard-coded to jquery-latest.js, which as highlighted here is bad practice as that branch is stuck on v1.10 for compatibility reasons.
- Injected jQuery on every page, which was not ideal on my shitty internet.
- Injected jQuery into only the top-level frame, ignoring the all_frames option (documented here).
- For some reason, a couple of them had
run_at: document_start, which doesn't allow them to load in the DOM.
- Required a page reload, which is absolutely not necessary.
As a result, I ended up coding jQuery Injector, a Chrome Extension that allows you to inject jQuery into all frames on a single page through an easy context-menu entry. It also allows you to specify any jQuery URL and specify URLs or partial-URLs to always inject into.
- Added the option to delete previous jQuery versions when injecting.
- Added an indicator for when jQuery is already present on the page.
- Added link to Options screen in the popup options panel.
- Bumped the default jQuery version to 3.2.1.
- Fixed a bug where the head tag would be placed after the body tag on pages with no original head tag.
- Fixed some styling/UI issues.
- Added a context-menu entry for embedded pdfs.
- Fixed a bug that made it impossible to inject into pages with no head tag.
- Fixed font-rendering in settings for newer Chrome versions.
The code can be found here and is licensed under the Apache License.