mirror of https://github.com/gorhill/uBlock.git
better manage platform-specific code for user-stylesheet support
This commit is contained in:
parent
6a0120340c
commit
e5f2e9701d
|
@ -1,7 +1,7 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2016-2017 The uBlock Origin authors
|
||||
Copyright (C) 2016-2018 The uBlock Origin authors
|
||||
|
||||
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
|
||||
|
@ -39,6 +39,14 @@
|
|||
// indexedDB.
|
||||
|
||||
vAPI.cacheStorage = (function() {
|
||||
|
||||
// Firefox-specific: we use indexedDB because chrome.storage.local() has
|
||||
// poor performance in Firefox. See:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1371255
|
||||
if ( vAPI.webextFlavor.soup.has('firefox') === false ) {
|
||||
return vAPI.cacheStorage;
|
||||
}
|
||||
|
||||
const STORAGE_NAME = 'uBlock0CacheStorage';
|
||||
var db;
|
||||
var pending = [];
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 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
|
||||
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';
|
||||
|
||||
// This file can be replaced by platform-specific code. If a platform is
|
||||
// known to NOT support user stylsheets, vAPI.supportsUserStylesheets can be
|
||||
// set to `false`.
|
||||
|
||||
// Chromium 66 and above supports user stylesheets:
|
||||
// https://github.com/gorhill/uBlock/issues/3588
|
||||
|
||||
vAPI.supportsUserStylesheets =
|
||||
/\bChrom(?:e|ium)\/(?:6[6789]|[789]|1\d\d)/.test(navigator.userAgent);
|
|
@ -21,20 +21,10 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
// For content pages
|
||||
// Packaging this file is optional: it is not necessary to package it if the
|
||||
// platform is known to support user stylesheets.
|
||||
|
||||
// Abort execution if our global vAPI object does not exist.
|
||||
// https://github.com/chrisaljoudi/uBlock/issues/456
|
||||
// https://github.com/gorhill/uBlock/issues/2029
|
||||
|
||||
// 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)
|
||||
) {
|
||||
if ( typeof vAPI === 'object' && vAPI.userStylesheet === undefined ) {
|
||||
// >>>>>>>> start of HUGE-IF-BLOCK
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
// For content pages
|
||||
// Packaging this file is optional: it is not necessary to package it if the
|
||||
// platform is known to not support user stylesheets.
|
||||
|
||||
if (
|
||||
typeof vAPI === 'object' &&
|
||||
vAPI.userStylesheet === undefined
|
||||
) {
|
||||
if ( typeof vAPI === 'object' && vAPI.supportsUserStylesheets ) {
|
||||
// >>>>>>>> start of HUGE-IF-BLOCK
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 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
|
||||
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';
|
||||
|
||||
// This file can be replaced by platform-specific code. If a platform is
|
||||
// known to NOT support user stylsheets, vAPI.supportsUserStylesheets can be
|
||||
// set to `false`.
|
||||
|
||||
// Chromium 66 and above supports user stylesheets:
|
||||
// https://github.com/gorhill/uBlock/issues/3588
|
||||
|
||||
vAPI.supportsUserStylesheets =
|
||||
/\bChrom(?:e|ium)\/(?:6[6789]|[789]|1\d\d)|\bFirefox\/\d/.test(navigator.userAgent);
|
|
@ -0,0 +1,26 @@
|
|||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 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
|
||||
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';
|
||||
|
||||
// User stylesheets are always supported with Firefox/webext .
|
||||
|
||||
vAPI.supportsUserStylesheets = true;
|
|
@ -24,14 +24,17 @@ cp platform/chromium/*.json $DES/
|
|||
cp LICENSE.txt $DES/
|
||||
|
||||
echo "*** uBlock0.chromium: concatenating content scripts"
|
||||
cat $DES/js/vapi-usercss.pseudo.js > /tmp/contentscript.js
|
||||
cat $DES/js/vapi-usercss.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/vapi-usercss.pseudo.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.pseudo.js
|
||||
rm $DES/js/vapi-usercss.js
|
||||
rm $DES/js/vapi-usercss.real.js
|
||||
rm $DES/js/vapi-usercss.pseudo.js
|
||||
|
||||
# Chrome store-specific
|
||||
cp -R $DES/_locales/nb $DES/_locales/no
|
||||
|
|
|
@ -26,16 +26,19 @@ cp LICENSE.txt $DES/
|
|||
|
||||
cp platform/webext/manifest.json $DES/
|
||||
cp platform/webext/polyfill.js $DES/js/
|
||||
cp platform/webext/vapi-usercss.js $DES/js/
|
||||
cp platform/webext/vapi-webrequest.js $DES/js/
|
||||
cp platform/webext/vapi-cachestorage.js $DES/js/
|
||||
|
||||
echo "*** uBlock0.webext: concatenating content scripts"
|
||||
cat $DES/js/vapi-usercss.real.js > /tmp/contentscript.js
|
||||
cat $DES/js/vapi-usercss.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.pseudo.js
|
||||
rm $DES/js/vapi-usercss.js
|
||||
rm $DES/js/vapi-usercss.real.js
|
||||
rm $DES/js/vapi-usercss.pseudo.js
|
||||
|
||||
# Webext-specific
|
||||
rm $DES/img/icon_128.png
|
||||
|
|
Loading…
Reference in New Issue