-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamically reload 3p css when noop-ing "3rd-party" cell
This should improve usability of uBO's hard-mode and "relax blocking mode" operations. This is the new default behavior. The previous behavior of forcing a reload of the page can be re-enabled by simply setting the `3p` bit of the advanced setting `blockingProfiles` to 1.
- Loading branch information
Showing
4 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
uBlock Origin - a browser extension to block requests. | ||
Copyright (C) 2020-present Raymond Hill | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see {http://www.gnu.org/licenses/}. | ||
Home: https://github.com/gorhill/uBlock | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/******************************************************************************/ | ||
|
||
(( ) => { | ||
if ( typeof vAPI !== 'object' ) { return; } | ||
|
||
if ( vAPI.load3rdPartyCSS ) { return; } | ||
vAPI.load3rdPartyCSS = true; | ||
|
||
const links = document.querySelectorAll('link[rel="stylesheet"]'); | ||
if ( links.length === 0 ) { return; } | ||
|
||
const toLoadMaybe = new Map(Array.from(links).map(a => [ a.href, a ])); | ||
|
||
for ( const sheet of Array.from(document.styleSheets) ) { | ||
let loaded = false; | ||
try { | ||
loaded = sheet.rules.length !== 0; | ||
} catch(ex) { | ||
} | ||
if ( loaded ) { continue; } | ||
const link = toLoadMaybe.get(sheet.href); | ||
if ( link === undefined ) { continue; } | ||
toLoadMaybe.delete(sheet.href); | ||
const clone = link.cloneNode(true); | ||
link.replaceWith(clone); | ||
} | ||
})(); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/******************************************************************************* | ||
DO NOT: | ||
- Remove the following code | ||
- Add code beyond the following code | ||
Reason: | ||
- https://github.com/gorhill/uBlock/pull/3721 | ||
- uBO never uses the return value from injected content scripts | ||
**/ | ||
|
||
void 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b779f1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you thought about images? Or it will be too much?
b779f1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and all the rest too.
b779f1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I call "the rest" is not trivial changes, so this will have to wait for next dev cycle. It's not a given images should be loaded, it feels like a personal preference to me, so this might need its own bit.
For frames, I started work on this then thew it away when I realized this was going to demand more work, which I don't want to start in this dev cycle. For scripts, I will need to experiment so also too late for current dev cycle. Probably both will need their specific bit to dictate whether dynamic reload is preferred or not.