|
|
|
@ -1,6 +1,13 @@ |
|
|
|
|
const LocalMessageDuplexStream = require('./lib/local-message-stream.js') |
|
|
|
|
const PortStream = require('./lib/port-stream.js') |
|
|
|
|
const ObjectMultiplex = require('./lib/obj-multiplex') |
|
|
|
|
const urlUtil = require('url') |
|
|
|
|
|
|
|
|
|
if (shouldInjectWeb3()) { |
|
|
|
|
setupInjection() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function setupInjection(){ |
|
|
|
|
|
|
|
|
|
// inject in-page script
|
|
|
|
|
var scriptTag = document.createElement('script') |
|
|
|
@ -34,3 +41,12 @@ reloadStream.on('error', console.error.bind(console)) |
|
|
|
|
pluginStream.on('close', function () { |
|
|
|
|
reloadStream.write({ method: 'reset' }) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function shouldInjectWeb3(){ |
|
|
|
|
var urlData = urlUtil.parse(window.location.href) |
|
|
|
|
var extension = urlData.pathname.split('.').slice(-1)[0] |
|
|
|
|
var shouldInject = (extension !== 'pdf') |
|
|
|
|
return shouldInject |
|
|
|
|
} |