Raymond Hill 2018-04-21 12:34:54 -04:00
parent 26e5b3f45d
commit 5386558e68
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 15 additions and 3 deletions

View File

@ -49,6 +49,12 @@ vAPI.resetLastError = function() {
};
vAPI.supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet');
// The real actual webextFlavor value may not be set in stone, so listen
// for possible future changes.
window.addEventListener('webextFlavor', function() {
vAPI.supportsUserStylesheets =
vAPI.webextFlavor.soup.has('user_stylesheet');
}, { once: true });
vAPI.insertCSS = function(tabId, details) {
return chrome.tabs.insertCSS(tabId, details, vAPI.resetLastError);
@ -721,8 +727,7 @@ vAPI.messaging.listen = function(listenerName, callback) {
/******************************************************************************/
vAPI.messaging.onPortMessage = (function() {
var messaging = vAPI.messaging,
supportsUserStylesheets = vAPI.supportsUserStylesheets;
var messaging = vAPI.messaging;
// Use a wrapper to avoid closure and to allow reuse.
var CallbackWrapper = function(port, request) {
@ -806,7 +811,7 @@ vAPI.messaging.onPortMessage = (function() {
frameId: sender.frameId,
matchAboutBlank: true
};
if ( supportsUserStylesheets ) {
if ( vAPI.supportsUserStylesheets ) {
details.cssOrigin = 'user';
}
if ( msg.add ) {

View File

@ -69,7 +69,9 @@ vAPI.webextFlavor = {
flavor.major = parseInt(info.version, 10) || 0;
soup.add(info.vendor.toLowerCase())
.add(info.name.toLowerCase());
soup.delete('user_stylesheet');
if ( flavor.major >= 53 ) { soup.add('user_stylesheet'); }
soup.delete('html_filtering');
if ( flavor.major >= 57 ) { soup.add('html_filtering'); }
dispatch();
});

View File

@ -543,6 +543,11 @@ FilterContainer.prototype.freeze = function() {
this.highlyGeneric.simple.str = µb.arrayFrom(this.highlyGeneric.simple.dict).join(',\n');
this.highlyGeneric.complex.str = µb.arrayFrom(this.highlyGeneric.complex.dict).join(',\n');
// https://www.reddit.com/r/uBlockOrigin/comments/8dkvqn/116_broken_loading_custom_filters_from_my_filters/
// Just in case. This can be removed once Firefox 60 ESR is out
// and widespread.
this.supportsUserStylesheets = vAPI.supportsUserStylesheets;
this.frozen = true;
};