mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Squashed commit of the following:
commit ab2b328cf1360a751fa1c58b8521f907eeb1ec50 Author: Raymond Hill <rhill@raymondhill.net> Date: Thu Apr 12 12:08:30 2018 -0400 fix #3588 commit c4ae7638dfa5a5c7ddec2f9dd2d2988450082542 Author: Raymond Hill <rhill@raymondhill.net> Date: Thu Apr 12 09:08:56 2018 -0400 detect user stylesheets support from content scripts (#3588)
This commit is contained in:
parent
5691b9d23f
commit
efcab14597
5 changed files with 34 additions and 18 deletions
|
@ -39,10 +39,7 @@ vAPI.cantWebsocket =
|
|||
|
||||
// https://issues.adblockplus.org/ticket/5695
|
||||
// - Good idea, adopted: cleaner way to detect user-stylesheet support.
|
||||
vAPI.supportsUserStylesheets =
|
||||
chrome.extensionTypes instanceof Object &&
|
||||
chrome.extensionTypes.CSSOrigin instanceof Object &&
|
||||
'USER' in chrome.extensionTypes.CSSOrigin;
|
||||
vAPI.supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet');
|
||||
vAPI.insertCSS = chrome.tabs.insertCSS;
|
||||
|
||||
var noopFunc = function(){};
|
||||
|
@ -843,9 +840,11 @@ vAPI.messaging.onPortMessage = (function() {
|
|||
details.code = cssText;
|
||||
cssPromises.push(chrome.tabs.insertCSS(tabId, details));
|
||||
}
|
||||
for ( cssText of msg.remove ) {
|
||||
details.code = cssText;
|
||||
cssPromises.push(chrome.tabs.removeCSS(tabId, details));
|
||||
if ( typeof chrome.tabs.removeCSS === 'function' ) {
|
||||
for ( cssText of msg.remove ) {
|
||||
details.code = cssText;
|
||||
cssPromises.push(chrome.tabs.removeCSS(tabId, details));
|
||||
}
|
||||
}
|
||||
if ( typeof callback === 'function' ) {
|
||||
Promise.all(cssPromises).then(() => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2017 Raymond Hill
|
||||
Copyright (C) 2017-2018 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
|
||||
|
@ -27,7 +27,15 @@
|
|||
// https://github.com/chrisaljoudi/uBlock/issues/456
|
||||
// https://github.com/gorhill/uBlock/issues/2029
|
||||
|
||||
if ( typeof vAPI === 'object' ) { // >>>>>>>> start of HUGE-IF-BLOCK
|
||||
// https://github.com/gorhill/uBlock/issues/3588
|
||||
// Chromium 66+ supports user stylesheets. Testing support against a regex is
|
||||
// (unfortunately) necessary from content scripts.
|
||||
|
||||
if (
|
||||
typeof vAPI === 'object' &&
|
||||
/\bEdge\/\d+|\bChrom(?:e|ium)\/(?:[45][0-9]|6[0-5])/.test(navigator.userAgent)
|
||||
) {
|
||||
// >>>>>>>> start of HUGE-IF-BLOCK
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
@ -543,4 +551,5 @@ vAPI.DOMFilterer.prototype = {
|
|||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
} // <<<<<<<< end of HUGE-IF-BLOCK
|
||||
// <<<<<<<< end of HUGE-IF-BLOCK
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2017 Raymond Hill
|
||||
Copyright (C) 2017-2018 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
|
||||
|
@ -23,7 +23,11 @@
|
|||
|
||||
// For content pages
|
||||
|
||||
if ( typeof vAPI === 'object' ) { // >>>>>>>> start of HUGE-IF-BLOCK
|
||||
if (
|
||||
typeof vAPI === 'object' &&
|
||||
vAPI.userStylesheet === undefined
|
||||
) {
|
||||
// >>>>>>>> start of HUGE-IF-BLOCK
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
@ -237,4 +241,5 @@ vAPI.DOMFilterer.prototype = {
|
|||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
} // <<<<<<<< end of HUGE-IF-BLOCK
|
||||
// <<<<<<<< end of HUGE-IF-BLOCK
|
||||
}
|
|
@ -24,11 +24,14 @@ cp platform/chromium/*.json $DES/
|
|||
cp LICENSE.txt $DES/
|
||||
|
||||
echo "*** uBlock0.chromium: concatenating content scripts"
|
||||
cat $DES/js/vapi-usercss.js > /tmp/contentscript.js
|
||||
cat $DES/js/vapi-usercss.pseudo.js > /tmp/contentscript.js
|
||||
echo >> /tmp/contentscript.js
|
||||
grep -v "^'use strict';$" $DES/js/vapi-usercss.real.js >> /tmp/contentscript.js
|
||||
echo >> /tmp/contentscript.js
|
||||
grep -v "^'use strict';$" $DES/js/contentscript.js >> /tmp/contentscript.js
|
||||
mv /tmp/contentscript.js $DES/js/contentscript.js
|
||||
rm $DES/js/vapi-usercss.js
|
||||
rm $DES/js/vapi-usercss.pseudo.js
|
||||
rm $DES/js/vapi-usercss.real.js
|
||||
|
||||
# Chrome store-specific
|
||||
cp -R $DES/_locales/nb $DES/_locales/no
|
||||
|
|
|
@ -28,14 +28,14 @@ cp platform/webext/manifest.json $DES/
|
|||
cp platform/webext/polyfill.js $DES/js/
|
||||
cp platform/webext/vapi-webrequest.js $DES/js/
|
||||
cp platform/webext/vapi-cachestorage.js $DES/js/
|
||||
cp platform/webext/vapi-usercss.js $DES/js/
|
||||
|
||||
echo "*** uBlock0.webext: concatenating content scripts"
|
||||
cat $DES/js/vapi-usercss.js > /tmp/contentscript.js
|
||||
cat $DES/js/vapi-usercss.real.js > /tmp/contentscript.js
|
||||
echo >> /tmp/contentscript.js
|
||||
grep -v "^'use strict';$" $DES/js/contentscript.js >> /tmp/contentscript.js
|
||||
mv /tmp/contentscript.js $DES/js/contentscript.js
|
||||
rm $DES/js/vapi-usercss.js
|
||||
rm $DES/js/vapi-usercss.pseudo.js
|
||||
rm $DES/js/vapi-usercss.real.js
|
||||
|
||||
# Webext-specific
|
||||
rm $DES/img/icon_128.png
|
||||
|
|
Loading…
Reference in a new issue