mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-02 00:42:45 +01:00
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);
|
||||
break;
|
||||
|
||||
case 'reloadTab':
|
||||
if ( vAPI.isBehindTheSceneTabId(request.tabId) === false ) {
|
||||
vAPI.tabs.reload(request.tabId, request.bypassCache === true);
|
||||
if ( request.select && vAPI.tabs.select ) {
|
||||
vAPI.tabs.select(request.tabId);
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/1954
|
||||
// In case of document-blocked page, navigate to blocked URL instead
|
||||
// of forcing a reload.
|
||||
case 'reloadTab': {
|
||||
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;
|
||||
|
||||
}
|
||||
case 'setWhitelist':
|
||||
µb.netWhitelist = µb.whitelistFromString(request.whitelist);
|
||||
µb.saveWhitelist();
|
||||
|
@ -1077,6 +1077,7 @@ const reloadTab = function(ev) {
|
||||
messaging.send('popupPanel', {
|
||||
what: 'reloadTab',
|
||||
tabId: popupData.tabId,
|
||||
url: popupData.pageURL,
|
||||
select: vAPI.webextFlavor.soup.has('mobile'),
|
||||
bypassCache: ev.ctrlKey || ev.metaKey || ev.shiftKey,
|
||||
});
|
||||
|
@ -339,14 +339,9 @@ const onPopupUpdated = (( ) => {
|
||||
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.
|
||||
if ( targetURL.startsWith(vAPI.getURL('document-blocked.html')) ) {
|
||||
const matches = /details=([^&]+)/.exec(targetURL);
|
||||
if ( matches !== null ) {
|
||||
targetURL = JSON.parse(decodeURIComponent(matches[1])).url;
|
||||
}
|
||||
}
|
||||
targetURL = µb.pageURLFromMaybeDocumentBlockedURL(targetURL);
|
||||
|
||||
// MUST be reset before code below is called.
|
||||
const fctxt = µb.filteringContext.duplicate();
|
||||
@ -683,6 +678,9 @@ housekeep itself.
|
||||
|
||||
// Update just force all properties to be updated to match the most recent
|
||||
// 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() {
|
||||
this.netFilteringReadTime = 0;
|
||||
if ( this.stack.length === 0 ) {
|
||||
@ -694,7 +692,7 @@ housekeep itself.
|
||||
return;
|
||||
}
|
||||
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.origin = originFromURI(this.normalURL);
|
||||
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
Block a user