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' ]
|
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) {
|
var addIFrame = function(iframe, dontObserve) {
|
||||||
// https://github.com/gorhill/uBlock/issues/162
|
// https://github.com/gorhill/uBlock/issues/162
|
||||||
// Be prepared to deal with possible change of src attribute.
|
// Be prepared to deal with possible change of src attribute.
|
||||||
|
@ -232,6 +244,7 @@ var uBlockCollapser = (function() {
|
||||||
|
|
||||||
var src = iframe.src;
|
var src = iframe.src;
|
||||||
if ( src === '' || typeof src !== 'string' ) {
|
if ( src === '' || typeof src !== 'string' ) {
|
||||||
|
primeLocalIFrame(iframe);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( src.lastIndexOf('http', 0) !== 0 ) {
|
if ( src.lastIndexOf('http', 0) !== 0 ) {
|
||||||
|
|
|
@ -136,6 +136,7 @@ var injectScripts = function(scripts) {
|
||||||
var scriptTag = document.createElement('script');
|
var scriptTag = document.createElement('script');
|
||||||
scriptTag.appendChild(document.createTextNode(scripts));
|
scriptTag.appendChild(document.createTextNode(scripts));
|
||||||
parent.appendChild(scriptTag);
|
parent.appendChild(scriptTag);
|
||||||
|
vAPI.injectedScripts = scripts;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue