mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
contentscript - fix inpage require and bundling
This commit is contained in:
parent
c9a984a237
commit
53a360b65d
@ -7,9 +7,9 @@ const ObjectMultiplex = require('obj-multiplex')
|
|||||||
const extension = require('extensionizer')
|
const extension = require('extensionizer')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
|
|
||||||
const inpagePath = path.join(__dirname, '..', '..', 'dist', 'chrome', 'scripts', 'inpage.js')
|
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'scripts', 'inpage.js')).toString()
|
||||||
const inpageString = fs.readFileSync(inpagePath).toString()
|
const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('scripts/inpage.js') + '\n'
|
||||||
const inpageText = inpageString + '//# sourceURL=' + extension.extension.getURL('scripts/inpage.js') + '\n'
|
const inpageBundle = inpageContent + inpageSuffix
|
||||||
|
|
||||||
// Eventually this streaming injection could be replaced with:
|
// Eventually this streaming injection could be replaced with:
|
||||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
|
||||||
@ -27,7 +27,7 @@ function setupInjection () {
|
|||||||
try {
|
try {
|
||||||
// inject in-page script
|
// inject in-page script
|
||||||
var scriptTag = document.createElement('script')
|
var scriptTag = document.createElement('script')
|
||||||
scriptTag.textContent = inpageText
|
scriptTag.textContent = inpageBundle
|
||||||
scriptTag.onload = function () { this.parentNode.removeChild(this) }
|
scriptTag.onload = function () { this.parentNode.removeChild(this) }
|
||||||
var container = document.head || document.documentElement
|
var container = document.head || document.documentElement
|
||||||
// append as first child
|
// append as first child
|
||||||
|
Loading…
Reference in New Issue
Block a user