mirror of https://github.com/gorhill/uBlock.git
Re. #1250: propagate injected scripts to local iframes
This commit is contained in:
parent
cdfdb570bb
commit
3eff3c62b0
|
@ -223,6 +223,18 @@ var uBlockCollapser = (function() {
|
|||
attributeFilter: [ 'src' ]
|
||||
};
|
||||
|
||||
var primeLocalIFrame = function(iframe) {
|
||||
// Should probably also copy injected styles.
|
||||
if ( vAPI.injectedScripts ) {
|
||||
var scriptTag = document.createElement('script');
|
||||
scriptTag.appendChild(document.createTextNode(vAPI.injectedScripts));
|
||||
var parent = iframe.contentDocument && iframe.contentDocument.head;
|
||||
if ( parent ) {
|
||||
parent.appendChild(scriptTag);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var addIFrame = function(iframe, dontObserve) {
|
||||
// https://github.com/gorhill/uBlock/issues/162
|
||||
// Be prepared to deal with possible change of src attribute.
|
||||
|
@ -232,6 +244,7 @@ var uBlockCollapser = (function() {
|
|||
|
||||
var src = iframe.src;
|
||||
if ( src === '' || typeof src !== 'string' ) {
|
||||
primeLocalIFrame(iframe);
|
||||
return;
|
||||
}
|
||||
if ( src.lastIndexOf('http', 0) !== 0 ) {
|
||||
|
|
|
@ -136,6 +136,7 @@ var injectScripts = function(scripts) {
|
|||
var scriptTag = document.createElement('script');
|
||||
scriptTag.appendChild(document.createTextNode(scripts));
|
||||
parent.appendChild(scriptTag);
|
||||
vAPI.injectedScripts = scripts;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue