diff --git a/src/js/messaging.js b/src/js/messaging.js index cacf32127adda..9137f26538fa7 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -2178,7 +2178,7 @@ const onMessage = function(request, sender, callback) { url: 'dashboard.html#3p-filters.html', select: true, }); - µb.scheduleAssetUpdater({ now: true, fetchDelay: 100, auto: request.manual !== true }); + µb.scheduleAssetUpdater({ now: true, fetchDelay: 100, auto: request.auto }); break; default: diff --git a/src/js/scriptlets/updater.js b/src/js/scriptlets/updater.js index 0eafc5daa2ffd..006b663a05951 100644 --- a/src/js/scriptlets/updater.js +++ b/src/js/scriptlets/updater.js @@ -51,11 +51,28 @@ function updateStockLists(target) { if ( updateURL.hostname !== 'ublockorigin.github.io') { return; } if ( updateURL.pathname !== '/uAssets/update-lists.html') { return; } const listkeys = updateURL.searchParams.get('listkeys') || ''; - if ( listkeys === '' ) { return true; } + if ( listkeys === '' ) { return; } + let auto = true; + const manual = updateURL.searchParams.get('manual'); + if ( manual === '1' ) { + auto = false; + } else if ( /^\d{6}$/.test(`${manual}`) ) { + const year = parseInt(manual.slice(0,2)) || 0; + const month = parseInt(manual.slice(2,4)) || 0; + const day = parseInt(manual.slice(4,6)) || 0; + if ( year !== 0 && month !== 0 && day !== 0 ) { + const date = new Date(); + date.setUTCFullYear(2000 + year, month - 1, day); + date.setUTCHours(0); + const then = date.getTime() / 1000 / 3600; + const now = Date.now() / 1000 / 3600; + auto = then < (now - 48) || then > (now + 48); + } + } vAPI.messaging.send('scriptlets', { what: 'updateLists', listkeys, - manual: updateURL.searchParams.get('manual') && true || false, + auto, }); return true; } catch (_) {