mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 09:09:38 +02:00
fix #3057
This commit is contained in:
parent
cd5c0ec05a
commit
c74526a895
@ -39,10 +39,21 @@ vAPI.chromiumVersion = (function(){
|
|||||||
var matches = /\bChrom(?:e|ium)\/(\d+)\b/.exec(navigator.userAgent);
|
var matches = /\bChrom(?:e|ium)\/(\d+)\b/.exec(navigator.userAgent);
|
||||||
return matches !== null ? parseInt(matches[1], 10) : NaN;
|
return matches !== null ? parseInt(matches[1], 10) : NaN;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
vAPI.cantWebsocket =
|
vAPI.cantWebsocket =
|
||||||
chrome.webRequest.ResourceType instanceof Object === false ||
|
chrome.webRequest.ResourceType instanceof Object === false ||
|
||||||
chrome.webRequest.ResourceType.WEBSOCKET !== 'websocket';
|
chrome.webRequest.ResourceType.WEBSOCKET !== 'websocket';
|
||||||
|
|
||||||
|
vAPI.webextFlavor = '';
|
||||||
|
if (
|
||||||
|
self.browser instanceof Object &&
|
||||||
|
typeof self.browser.runtime.getBrowserInfo === 'function'
|
||||||
|
) {
|
||||||
|
self.browser.runtime.getBrowserInfo().then(function(info) {
|
||||||
|
vAPI.webextFlavor = info.vendor + '-' + info.name + '-' + info.version;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var noopFunc = function(){};
|
var noopFunc = function(){};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -301,14 +312,19 @@ vAPI.tabs.registerListeners = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var onCreatedNavigationTarget = function(details) {
|
var onCreatedNavigationTarget = function(details) {
|
||||||
//console.debug('onCreatedNavigationTarget: popup candidate tab id %d = "%s"', details.tabId, details.url);
|
if ( typeof details.url !== 'string' ) {
|
||||||
|
details.url = '';
|
||||||
|
}
|
||||||
if ( reGoodForWebRequestAPI.test(details.url) === false ) {
|
if ( reGoodForWebRequestAPI.test(details.url) === false ) {
|
||||||
details.frameId = 0;
|
details.frameId = 0;
|
||||||
details.url = sanitizeURL(details.url);
|
details.url = sanitizeURL(details.url);
|
||||||
onNavigationClient(details);
|
onNavigationClient(details);
|
||||||
}
|
}
|
||||||
if ( typeof vAPI.tabs.onPopupCreated === 'function' ) {
|
if ( typeof vAPI.tabs.onPopupCreated === 'function' ) {
|
||||||
vAPI.tabs.onPopupCreated(details.tabId.toString(), details.sourceTabId.toString());
|
vAPI.tabs.onPopupCreated(
|
||||||
|
details.tabId.toString(),
|
||||||
|
details.sourceTabId.toString()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -472,12 +488,19 @@ vAPI.tabs.open = function(details) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/3053#issuecomment-332276818
|
||||||
|
// - Do not try to lookup uBO's own pages with FF 55 or less.
|
||||||
|
if ( /^Mozilla-Firefox-5[2-5]\./.test(vAPI.webextFlavor) ) {
|
||||||
|
wrapper();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// https://developer.chrome.com/extensions/tabs#method-query
|
// https://developer.chrome.com/extensions/tabs#method-query
|
||||||
// "Note that fragment identifiers are not matched."
|
// "Note that fragment identifiers are not matched."
|
||||||
// It's a lie, fragment identifiers ARE matched. So we need to remove the
|
// It's a lie, fragment identifiers ARE matched. So we need to remove the
|
||||||
// fragment.
|
// fragment.
|
||||||
var pos = targetURL.indexOf('#');
|
var pos = targetURL.indexOf('#'),
|
||||||
var targetURLWithoutHash = pos === -1 ? targetURL : targetURL.slice(0, pos);
|
targetURLWithoutHash = pos === -1 ? targetURL : targetURL.slice(0, pos);
|
||||||
|
|
||||||
chrome.tabs.query({ url: targetURLWithoutHash }, function(tabs) {
|
chrome.tabs.query({ url: targetURLWithoutHash }, function(tabs) {
|
||||||
if ( chrome.runtime.lastError ) { /* noop */ }
|
if ( chrome.runtime.lastError ) { /* noop */ }
|
||||||
|
@ -77,8 +77,23 @@ setScriptDirection(vAPI.i18n('@@ui_locale'));
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/3057
|
||||||
|
// - webNavigation.onCreatedNavigationTarget become broken on Firefox when we
|
||||||
|
// try to make the popup panel close itself.
|
||||||
|
|
||||||
vAPI.closePopup = function() {
|
vAPI.closePopup = function() {
|
||||||
window.open('','_self').close();
|
if (
|
||||||
|
self.browser instanceof Object &&
|
||||||
|
typeof self.browser.runtime.getBrowserInfo === 'function'
|
||||||
|
) {
|
||||||
|
self.browser.runtime.getBrowserInfo().then(function(info) {
|
||||||
|
if ( info.name !== 'Firefox' ) {
|
||||||
|
window.open('', '_self').close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.open('', '_self').close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -632,7 +632,7 @@ var gotoPick = function() {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var gotoURL = function(ev) {
|
var gotoURL = function(ev) {
|
||||||
if ( this.hasAttribute('href') === false) {
|
if ( this.hasAttribute('href') === false ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user