mirror of https://github.com/gorhill/uBlock.git
Make popup panel reflect state of the actual blocked page
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1954
This commit is contained in:
parent
707609dc86
commit
60d1206215
|
@ -299,15 +299,24 @@ const onMessage = function(request, sender, callback) {
|
||||||
µb.openNewTab(request.details);
|
µb.openNewTab(request.details);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'reloadTab':
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1954
|
||||||
if ( vAPI.isBehindTheSceneTabId(request.tabId) === false ) {
|
// In case of document-blocked page, navigate to blocked URL instead
|
||||||
vAPI.tabs.reload(request.tabId, request.bypassCache === true);
|
// of forcing a reload.
|
||||||
if ( request.select && vAPI.tabs.select ) {
|
case 'reloadTab': {
|
||||||
vAPI.tabs.select(request.tabId);
|
if ( vAPI.isBehindTheSceneTabId(request.tabId) ) { break; }
|
||||||
|
const { tabId, bypassCache, url, select } = request;
|
||||||
|
vAPI.tabs.get(tabId).then(tab => {
|
||||||
|
if ( url && tab && url !== tab.url ) {
|
||||||
|
vAPI.tabs.replace(tabId, url);
|
||||||
|
} else {
|
||||||
|
vAPI.tabs.reload(tabId, bypassCache === true);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
if ( select && vAPI.tabs.select ) {
|
||||||
|
vAPI.tabs.select(tabId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'setWhitelist':
|
case 'setWhitelist':
|
||||||
µb.netWhitelist = µb.whitelistFromString(request.whitelist);
|
µb.netWhitelist = µb.whitelistFromString(request.whitelist);
|
||||||
µb.saveWhitelist();
|
µb.saveWhitelist();
|
||||||
|
|
|
@ -1077,6 +1077,7 @@ const reloadTab = function(ev) {
|
||||||
messaging.send('popupPanel', {
|
messaging.send('popupPanel', {
|
||||||
what: 'reloadTab',
|
what: 'reloadTab',
|
||||||
tabId: popupData.tabId,
|
tabId: popupData.tabId,
|
||||||
|
url: popupData.pageURL,
|
||||||
select: vAPI.webextFlavor.soup.has('mobile'),
|
select: vAPI.webextFlavor.soup.has('mobile'),
|
||||||
bypassCache: ev.ctrlKey || ev.metaKey || ev.shiftKey,
|
bypassCache: ev.ctrlKey || ev.metaKey || ev.shiftKey,
|
||||||
});
|
});
|
||||||
|
|
|
@ -339,14 +339,9 @@ const onPopupUpdated = (( ) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the page URL is that of our "blocked page" URL, extract the URL
|
// If the page URL is that of our document-blocked URL, extract the URL
|
||||||
// of the page which was blocked.
|
// of the page which was blocked.
|
||||||
if ( targetURL.startsWith(vAPI.getURL('document-blocked.html')) ) {
|
targetURL = µb.pageURLFromMaybeDocumentBlockedURL(targetURL);
|
||||||
const matches = /details=([^&]+)/.exec(targetURL);
|
|
||||||
if ( matches !== null ) {
|
|
||||||
targetURL = JSON.parse(decodeURIComponent(matches[1])).url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MUST be reset before code below is called.
|
// MUST be reset before code below is called.
|
||||||
const fctxt = µb.filteringContext.duplicate();
|
const fctxt = µb.filteringContext.duplicate();
|
||||||
|
@ -683,6 +678,9 @@ housekeep itself.
|
||||||
|
|
||||||
// Update just force all properties to be updated to match the most recent
|
// Update just force all properties to be updated to match the most recent
|
||||||
// root URL.
|
// root URL.
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1954
|
||||||
|
// In case of document-blocked page, use the blocked page URL as the
|
||||||
|
// context.
|
||||||
TabContext.prototype.update = function() {
|
TabContext.prototype.update = function() {
|
||||||
this.netFilteringReadTime = 0;
|
this.netFilteringReadTime = 0;
|
||||||
if ( this.stack.length === 0 ) {
|
if ( this.stack.length === 0 ) {
|
||||||
|
@ -694,7 +692,7 @@ housekeep itself.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const stackEntry = this.stack[this.stack.length - 1];
|
const stackEntry = this.stack[this.stack.length - 1];
|
||||||
this.rawURL = stackEntry.url;
|
this.rawURL = µb.pageURLFromMaybeDocumentBlockedURL(stackEntry.url);
|
||||||
this.normalURL = µb.normalizeTabURL(this.tabId, this.rawURL);
|
this.normalURL = µb.normalizeTabURL(this.tabId, this.rawURL);
|
||||||
this.origin = originFromURI(this.normalURL);
|
this.origin = originFromURI(this.normalURL);
|
||||||
this.rootHostname = hostnameFromURI(this.origin);
|
this.rootHostname = hostnameFromURI(this.origin);
|
||||||
|
|
|
@ -656,3 +656,16 @@ const matchBucket = function(url, hostname, bucket, start) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
µb.pageURLFromMaybeDocumentBlockedURL = function(pageURL) {
|
||||||
|
if ( pageURL.startsWith(vAPI.getURL('/document-blocked.html?')) ) {
|
||||||
|
try {
|
||||||
|
const url = new URL(pageURL);
|
||||||
|
return JSON.parse(url.searchParams.get('details')).url;
|
||||||
|
} catch(ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pageURL;
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue