Closed Bug 1480345 Opened 7 years ago Closed 7 years ago

Add the ability to inject scripts in the current page (:inject)

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: fvsch, Unassigned)

Details

The GCLI had an inject command that could be used to inject scripts in the current page. I think it also had some some shortcuts such as `inject jquery` that resolved to preconfigured URLs? This was probably not used a lot, since when it got broken last year it took a while to get a bug report (bug 1409428). It would still be useful for injecting scripts in the inspected page for testing. One alternative for console users looks like: document.body.insertAdjacentHTML('beforeend', '<script src="script_url_here"></script>') which is a bit painful to type, compared to: :inject 'script_url_here' To make it more useful even, it might be possible to load JS from unpkg.com. For instance `:inject jquery` could resolve to `:inject https://unpkg.com/jquery`, which loads https://unpkg.com/jquery@3.3.1/dist/jquery.js (Trouble is, not all packages have a main file that is suitable for loading in a web page; many point to a CommonJS file. But they may have a `"browser": "relative_url"` key in package.json.)
Meta bug is bug 1429421.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

Florens, it looks like dynamic import provides this right?
Should we close this bug?

Flags: needinfo?(florens)

I think we can close it.

I'm a bit concerned about the documentation and developer experience side, because users may not know that it's a possibility. At the same time, I'm not seeing this need expressed by many users so it's probably fairly niche? I don't think the GCLI inject command had a lot of use.

Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(florens)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.