[mv3] Address various issues for Safari build

This commit is contained in:
Raymond Hill 2025-05-02 14:33:33 -04:00
parent 6a088a7477
commit 48146f8351
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
6 changed files with 139 additions and 16 deletions

View file

@ -5,10 +5,11 @@ run_options := $(filter-out $@,$(MAKECMDGOALS))
mv3-chromium mv3-firefox mv3-edge mv3-safari \
compare maxcost medcost mincost modifiers record wasm
sources := $(wildcard assets/* assets/*/* dist/version src/* src/*/* src/*/*/* src/*/*/*/*)
platform := $(wildcard platform/* platform/*/* platform/*/*/* platform/*/*/*/* platform/*/*/*/*/*)
sources := ./dist/version $(shell find ./assets -type f) $(shell find ./src -type f)
platform := $(wildcard platform/**/*)
assets := dist/build/uAssets
mv3-data := $(wildcard dist/build/mv3-data/*)
mv3-data := $(shell find ./dist/build/mv3-data -type f)
mv3-safari-deps := $(shell find ./platform/mv3/extension -type f) $(wildcard platform/mv3/safari/*)
all: chromium firefox npm
@ -80,8 +81,10 @@ dist/build/uBOLite.edge: tools/make-mv3.sh tools/make-edge.mjs $(sources) $(plat
mv3-edge: dist/build/uBOLite.edge
dist/build/uBOLite.safari: tools/make-mv3.sh $(sources) $(platform) $(mv3-data) dist/build/mv3-data
dist/build/uBOLite.safari: tools/make-mv3.sh $(sources) $(mv3-safari-deps) $(mv3-data) dist/build/mv3-data
tools/make-mv3.sh safari
node platform/mv3/safari/patch-extension.js \
packageDir=./dist/build/uBOLite.safari
mv3-safari: dist/build/uBOLite.safari

View file

@ -1,5 +1,6 @@
.filteringModeSlider {
align-items: center;
container-type: size;
display: flex;
height: 60px;
justify-content: center;
@ -11,9 +12,9 @@
background-color: var(--surface-1);
box-sizing: border-box;
border-radius: 30% 15% / 15% 30%;
height: 100%;
height: calc(25cqw + 2px);
position: absolute;
width: calc(25% + 2px);
width: calc(25cqw + 2px);
z-index: 10;
}

View file

@ -70,9 +70,14 @@ body[data-forbid~="dashboard"] #gotoDashboard {
display: none;
}
.lrspacer {
padding-left: var(--default-gap-small);
padding-right: var(--default-gap-small);
}
#filteringModeText {
color: var(--ink-3);
margin: var(--default-gap-small);
margin-bottom: var(--default-gap-small);
margin-top: 0;
text-align: center;
text-transform: lowercase;
@ -95,7 +100,8 @@ body[data-forbid~="dashboard"] #gotoDashboard {
.filteringModeSlider {
align-self: center;
margin: var(--popup-gap);
margin-bottom: var(--popup-gap);
margin-top: var(--popup-gap);
width: calc(var(--popup-main-min-width) - 1em);
}

View file

@ -17,15 +17,20 @@
<div id="main">
<div id="hostname"><span></span>&shy;<span></span></div>
<!-- -------- -->
<div class="filteringModeSlider">
<div class="filteringModeButton"><div></div></div>
<span data-level="0"></span>
<span data-level="1"></span>
<span data-level="2"></span>
<span data-level="3"></span>
<div class="lrspacer">
<div class="filteringModeSlider">
<div class="filteringModeButton"><div></div></div>
<span data-level="0"></span>
<span data-level="1"></span>
<span data-level="2"></span>
<span data-level="3"></span>
</div>
</div>
<!-- -------- -->
<div class="lrspacer">
<div id="filteringModeText"><label data-i18n="popupFilteringModeLabel">_</label><br><span>_</span><span></span></div>
</div>
<!-- -------- -->
<div id="filteringModeText"><label data-i18n="popupFilteringModeLabel">_</label><br><span>_</span><span></span></div>
<div class="toolRibbon pageTools">
<span id="gotoZapper" class="fa-icon tool enabled" data-i18n-title="zapperTipEnter">bolt<span class="caption" data-i18n="zapperTipEnter"></span></span>
<span id="showMatchedRules" class="fa-icon tool" tabindex="0" title="Show matched rules">list-alt<span class="caption">Show matched rules</span></span>

View file

@ -6,7 +6,8 @@
"author": "Raymond Hill",
"background": {
"scripts": [ "/js/background.js" ],
"type": "module"
"type": "module",
"persistent": false
},
"commands": {
"enter-zapper-mode": {

View file

@ -0,0 +1,107 @@
/*******************************************************************************
uBlock Origin - a comprehensive, efficient content blocker
Copyright (C) 2025-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
*/
import fs from 'fs/promises';
import process from 'process';
/******************************************************************************/
const commandLineArgs = (( ) => {
const args = new Map();
let name, value;
for ( const arg of process.argv.slice(2) ) {
const pos = arg.indexOf('=');
if ( pos === -1 ) {
name = arg;
value = '';
} else {
name = arg.slice(0, pos);
value = arg.slice(pos+1);
}
args.set(name, value);
}
return args;
})();
/******************************************************************************/
// Apple store rejects when description (extShortDesc) is longer than 112
// characters.
async function fixLongDescription(path) {
let text = await fs.readFile(path, { encoding: 'utf8' });
const messages = JSON.parse(text);
let message = messages.extShortDesc.message;
if ( message.length <= 112 ) { return; }
const pos = message.indexOf('.');
if ( pos !== -1 ) {
message = message.slice(0, pos+1);
}
if ( message.length >= 112 ) {
message = `${message.slice(0, 111)}`;
}
messages.extShortDesc.message = message;
text = JSON.stringify(messages, null, 2);
await fs.writeFile(path, text);
}
async function fixLongDescriptions() {
const promises = [];
const packageDir = commandLineArgs.get('packageDir');
const entries = await fs.readdir(`${packageDir}/_locales/`, { withFileTypes: true });
for ( const entry of entries ) {
if ( entry.isDirectory() === false ) { continue; }
promises.push(fixLongDescription(`${packageDir}/_locales/${entry.name}/messages.json`));
}
return Promise.all(promises);
}
/******************************************************************************/
// Apple store rejects when version has four components.
async function fixManifest() {
const packageDir = commandLineArgs.get('packageDir');
const path = `${packageDir}/manifest.json`;
let text = await fs.readFile(path, { encoding: 'utf8' });
const manifest = JSON.parse(text);
const match = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(manifest.version);
const month = parseInt(match[2], 10);
const dayofmonth = parseInt(match[3], 10);
const monthday /* sort of */ = month * 100 + dayofmonth;
manifest.version = `${match[1]}.${monthday}.${match[4]}`;
text = JSON.stringify(manifest, null, 2);
await fs.writeFile(path, text);
}
/******************************************************************************/
async function main() {
await Promise.all([
fixLongDescriptions(),
fixManifest(),
]);
}
main();
/******************************************************************************/