mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Add $currentISODate$
to trusted-set-local-storage-item
scriptlet
Related feedback: - https://github.com/uBlockOrigin/uAssets/issues/19120#issuecomment-1646524557 Additionally, improve logging in `m3u-prune` scriptlet.
This commit is contained in:
parent
da8fe2f950
commit
8ddad9e39b
@ -782,6 +782,8 @@ function setLocalStorageItemCore(
|
|||||||
value = Date.now();
|
value = Date.now();
|
||||||
} else if ( value === '$currentDate$' ) {
|
} else if ( value === '$currentDate$' ) {
|
||||||
value = `${Date()}`;
|
value = `${Date()}`;
|
||||||
|
} else if ( value === '$currentISODate$' ) {
|
||||||
|
value = (new Date()).toISOString();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( trustedValues.includes(value.toLowerCase()) === false ) {
|
if ( trustedValues.includes(value.toLowerCase()) === false ) {
|
||||||
@ -2429,6 +2431,7 @@ function m3uPrune(
|
|||||||
const options = getExtraArgs(Array.from(arguments), 2);
|
const options = getExtraArgs(Array.from(arguments), 2);
|
||||||
const logLevel = shouldLog(options);
|
const logLevel = shouldLog(options);
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
|
const uboLog = logLevel ? ((...args) => safe.uboLog(...args)) : (( ) => { });
|
||||||
const regexFromArg = arg => {
|
const regexFromArg = arg => {
|
||||||
if ( arg === '' ) { return /^/; }
|
if ( arg === '' ) { return /^/; }
|
||||||
const match = /^\/(.+)\/([gms]*)$/.exec(arg);
|
const match = /^\/(.+)\/([gms]*)$/.exec(arg);
|
||||||
@ -2447,17 +2450,22 @@ function m3uPrune(
|
|||||||
if ( lines[i].startsWith('#EXT-X-CUE:TYPE="SpliceOut"') === false ) {
|
if ( lines[i].startsWith('#EXT-X-CUE:TYPE="SpliceOut"') === false ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
uboLog('m3u-prune: discarding', `\n\t${lines[i]}`);
|
||||||
lines[i] = undefined; i += 1;
|
lines[i] = undefined; i += 1;
|
||||||
if ( lines[i].startsWith('#EXT-X-ASSET:CAID') ) {
|
if ( lines[i].startsWith('#EXT-X-ASSET:CAID') ) {
|
||||||
|
uboLog(`\t${lines[i]}`);
|
||||||
lines[i] = undefined; i += 1;
|
lines[i] = undefined; i += 1;
|
||||||
}
|
}
|
||||||
if ( lines[i].startsWith('#EXT-X-SCTE35:') ) {
|
if ( lines[i].startsWith('#EXT-X-SCTE35:') ) {
|
||||||
|
uboLog(`\t${lines[i]}`);
|
||||||
lines[i] = undefined; i += 1;
|
lines[i] = undefined; i += 1;
|
||||||
}
|
}
|
||||||
if ( lines[i].startsWith('#EXT-X-CUE-IN') ) {
|
if ( lines[i].startsWith('#EXT-X-CUE-IN') ) {
|
||||||
|
uboLog(`\t${lines[i]}`);
|
||||||
lines[i] = undefined; i += 1;
|
lines[i] = undefined; i += 1;
|
||||||
}
|
}
|
||||||
if ( lines[i].startsWith('#EXT-X-SCTE35:') ) {
|
if ( lines[i].startsWith('#EXT-X-SCTE35:') ) {
|
||||||
|
uboLog(`\t${lines[i]}`);
|
||||||
lines[i] = undefined; i += 1;
|
lines[i] = undefined; i += 1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -2465,8 +2473,10 @@ function m3uPrune(
|
|||||||
const pruneInfBlock = (lines, i) => {
|
const pruneInfBlock = (lines, i) => {
|
||||||
if ( lines[i].startsWith('#EXTINF') === false ) { return false; }
|
if ( lines[i].startsWith('#EXTINF') === false ) { return false; }
|
||||||
if ( reM3u.test(lines[i+1]) === false ) { return false; }
|
if ( reM3u.test(lines[i+1]) === false ) { return false; }
|
||||||
|
uboLog('m3u-prune: discarding', `\n\t${lines[i]}, \n\t${lines[i+1]}`);
|
||||||
lines[i] = lines[i+1] = undefined; i += 2;
|
lines[i] = lines[i+1] = undefined; i += 2;
|
||||||
if ( lines[i].startsWith('#EXT-X-DISCONTINUITY') ) {
|
if ( lines[i].startsWith('#EXT-X-DISCONTINUITY') ) {
|
||||||
|
uboLog(`\t${lines[i]}`);
|
||||||
lines[i] = undefined; i += 1;
|
lines[i] = undefined; i += 1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -2503,11 +2513,9 @@ function m3uPrune(
|
|||||||
}
|
}
|
||||||
text = before.trim() + '\n' + after.trim();
|
text = before.trim() + '\n' + after.trim();
|
||||||
reM3u.lastIndex = before.length + 1;
|
reM3u.lastIndex = before.length + 1;
|
||||||
if ( logLevel ) {
|
uboLog('m3u-prune: discarding\n',
|
||||||
safe.uboLog('m3u-prune: discarding\n',
|
|
||||||
discard.split(/\n+/).map(s => `\t${s}`).join('\n')
|
discard.split(/\n+/).map(s => `\t${s}`).join('\n')
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if ( reM3u.global === false ) { break; }
|
if ( reM3u.global === false ) { break; }
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
|
Loading…
Reference in New Issue
Block a user