mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Injects user styles and content scripts in about:blank
frames
Related issues: - https://github.com/uBlockOrigin/uBlock-issues/issues/688 - https://github.com/uBlockOrigin/uBlock-issues/issues/1164 `match_about_blank` is now used for content scripts and user styles.
This commit is contained in:
parent
fb0a442a9a
commit
221983646e
@ -39,8 +39,9 @@
|
|||||||
"/js/vapi-client.js",
|
"/js/vapi-client.js",
|
||||||
"/js/contentscript.js"
|
"/js/contentscript.js"
|
||||||
],
|
],
|
||||||
"run_at": "document_start",
|
"all_frames": true,
|
||||||
"all_frames": true
|
"match_about_blank": true,
|
||||||
|
"run_at": "document_start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"matches": [
|
"matches": [
|
||||||
|
@ -49,8 +49,9 @@
|
|||||||
"/js/vapi-client.js",
|
"/js/vapi-client.js",
|
||||||
"/js/contentscript.js"
|
"/js/contentscript.js"
|
||||||
],
|
],
|
||||||
"run_at": "document_start",
|
"all_frames": true,
|
||||||
"all_frames": true
|
"match_about_blank": true,
|
||||||
|
"run_at": "document_start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"matches": [
|
"matches": [
|
||||||
|
@ -30,16 +30,17 @@
|
|||||||
},
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"all_frames": true,
|
"matches": [
|
||||||
|
"http://*/*",
|
||||||
|
"https://*/*"
|
||||||
|
],
|
||||||
"js": [
|
"js": [
|
||||||
"js/vapi.js",
|
"js/vapi.js",
|
||||||
"js/vapi-client.js",
|
"js/vapi-client.js",
|
||||||
"js/contentscript.js"
|
"js/contentscript.js"
|
||||||
],
|
],
|
||||||
"matches": [
|
"all_frames": true,
|
||||||
"http://*/*",
|
"match_about_blank": true,
|
||||||
"https://*/*"
|
|
||||||
],
|
|
||||||
"run_at": "document_start"
|
"run_at": "document_start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -30,8 +30,9 @@
|
|||||||
"/js/vapi-client.js",
|
"/js/vapi-client.js",
|
||||||
"/js/contentscript.js"
|
"/js/contentscript.js"
|
||||||
],
|
],
|
||||||
"run_at": "document_start",
|
"all_frames": true,
|
||||||
"all_frames": true
|
"match_about_blank": true,
|
||||||
|
"run_at": "document_start"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"matches": [
|
"matches": [
|
||||||
|
@ -1053,27 +1053,14 @@ vAPI.domCollapser = (function() {
|
|||||||
attributeFilter: [ 'src' ]
|
attributeFilter: [ 'src' ]
|
||||||
};
|
};
|
||||||
|
|
||||||
// The injected scriptlets are those which were injected in the current
|
|
||||||
// document, from within `bootstrapPhase1`, and which scriptlets are
|
|
||||||
// selectively looked-up from:
|
|
||||||
// https://github.com/uBlockOrigin/uAssets/blob/master/filters/resources.txt
|
|
||||||
const primeLocalIFrame = function(iframe) {
|
|
||||||
if ( vAPI.injectedScripts ) {
|
|
||||||
vAPI.injectScriptlet(iframe.contentDocument, vAPI.injectedScripts);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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.
|
||||||
const addIFrame = function(iframe, dontObserve) {
|
const addIFrame = function(iframe, dontObserve) {
|
||||||
if ( dontObserve !== true ) {
|
if ( dontObserve !== true ) {
|
||||||
iframeSourceObserver.observe(iframe, iframeSourceObserverOptions);
|
iframeSourceObserver.observe(iframe, iframeSourceObserverOptions);
|
||||||
}
|
}
|
||||||
const src = iframe.src;
|
const src = iframe.src;
|
||||||
if ( src === '' || typeof src !== 'string' ) {
|
if ( typeof src !== 'string' || src === '' ) { return; }
|
||||||
primeLocalIFrame(iframe);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( src.startsWith('http') === false ) { return; }
|
if ( src.startsWith('http') === false ) { return; }
|
||||||
toFilter.push({ type: 'sub_frame', url: iframe.src });
|
toFilter.push({ type: 'sub_frame', url: iframe.src });
|
||||||
add(iframe);
|
add(iframe);
|
||||||
|
@ -959,7 +959,8 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) {
|
|||||||
code: out.injected + '\n{display:none!important;}',
|
code: out.injected + '\n{display:none!important;}',
|
||||||
cssOrigin: 'user',
|
cssOrigin: 'user',
|
||||||
frameId: request.frameId,
|
frameId: request.frameId,
|
||||||
runAt: 'document_start'
|
matchAboutBlank: true,
|
||||||
|
runAt: 'document_start',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,7 +1152,8 @@ FilterContainer.prototype.retrieveSpecificSelectors = function(
|
|||||||
code: '',
|
code: '',
|
||||||
cssOrigin: 'user',
|
cssOrigin: 'user',
|
||||||
frameId: request.frameId,
|
frameId: request.frameId,
|
||||||
runAt: 'document_start'
|
matchAboutBlank: true,
|
||||||
|
runAt: 'document_start',
|
||||||
};
|
};
|
||||||
if ( out.injectedHideFilters.length !== 0 ) {
|
if ( out.injectedHideFilters.length !== 0 ) {
|
||||||
details.code = out.injectedHideFilters + '\n{display:none!important;}';
|
details.code = out.injectedHideFilters + '\n{display:none!important;}';
|
||||||
|
Loading…
Reference in New Issue
Block a user