MetaMask / MetaMask/metamask-extension
Question about the behavior of content script.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
### What is this about?
I was wondering why it clears the script tag when I inject.
I'm wondering if there's something wrong with it?
https://github.com/MetaMask/metamask-extension/blob/a3a99aaaebc1a5b7edae6678a8452dd72b887441/app/scripts/contentscript.js#L79
```js
function injectScript(content) {
try {
const container = document.head || document.documentElement;
const scriptTag = document.createElement('script');
scriptTag.setAttribute('async', 'false');
scriptTag.textContent = content;
container.insertBefore(scriptTag, container.children[0]);
container.removeChild(scriptTag);
} catch (error) {
console.error('MetaMask: Provider injection failed.', error);
}
}
```
### Scenario
_No response_
### Design
_No response_
### Technical Details
_No response_
### Threat Modeling Framework
_No response_
### Acceptance Criteria
_No response_
### References
_No response_
Contributor guide
Research direction
Start with app/scripts/contentscript.js at line 79 and read the surrounding injectScript function. Trace how the injected content is used and determine whether removing the script tag is expected; document the explanation or identify a concrete behavior that needs changing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100