mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01:00
Prevent dashboard from loading at browser launch until ready
Related discussion: - https://github.com/uBlockOrigin/uAssets/discussions/16939 Various feedback of people trying to interact with uBO's dashboard at browser launch, before uBO's main process is fully initialized, causing confusion, and potential loss of data.
This commit is contained in:
parent
0cfc4ee396
commit
5c92d95143
4 changed files with 30 additions and 1 deletions
|
@ -7,6 +7,9 @@ html, body {
|
|||
position: relative;
|
||||
width: 100vw;
|
||||
}
|
||||
body.notReady {
|
||||
display: none;
|
||||
}
|
||||
#dashboard-nav {
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
<link rel="shortcut icon" type="image/png" href="img/icon_64.png">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="notReady">
|
||||
|
||||
<div id="dashboard-nav">
|
||||
<span class="logo"><img data-i18n-title="extName" src="img/ublock.svg"></span><!--
|
||||
--><button class="tabButton" type="button" data-pane="settings.html" data-i18n="settingsPageName" tabindex="0"></button><!--
|
||||
|
|
|
@ -102,6 +102,27 @@ if ( self.location.hash.slice(1) === 'no-dashboard.html' ) {
|
|||
}
|
||||
|
||||
(async ( ) => {
|
||||
// Wait for uBO's main process to be ready
|
||||
await new Promise(resolve => {
|
||||
const check = ( ) => {
|
||||
vAPI.messaging.send('dashboard', {
|
||||
what: 'readyToFilter'
|
||||
}).then(response => {
|
||||
if ( response ) { return resolve(true); }
|
||||
const iframe = qs$('#iframe');
|
||||
if ( iframe.src !== '' ) {
|
||||
iframe.src = '';
|
||||
}
|
||||
vAPI.setTimeout(check, 250);
|
||||
}).catch(( ) => {
|
||||
vAPI.setTimeout(check, 250);
|
||||
});
|
||||
};
|
||||
check();
|
||||
});
|
||||
|
||||
dom.cl.remove(dom.body, 'notReady');
|
||||
|
||||
const results = await Promise.all([
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/106
|
||||
vAPI.messaging.send('dashboard', { what: 'dashboardConfig' }),
|
||||
|
|
|
@ -312,6 +312,10 @@ const onMessage = function(request, sender, callback) {
|
|||
µb.openNewTab(request.details);
|
||||
break;
|
||||
|
||||
case 'readyToFilter':
|
||||
response = µb.readyToFilter;
|
||||
break;
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/1954
|
||||
// In case of document-blocked page, navigate to blocked URL instead
|
||||
// of forcing a reload.
|
||||
|
|
Loading…
Reference in a new issue