mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Badge number sometimes disappeared in Safari
This commit is contained in:
parent
56be0b6025
commit
64c37ccd1d
2 changed files with 37 additions and 2 deletions
|
@ -718,6 +718,11 @@ if (window.chrome) {
|
|||
e.stopPropagation();
|
||||
}
|
||||
|
||||
if (e.message.middleClickURL) {
|
||||
vAPI.lastMiddleClick = e.message;
|
||||
return;
|
||||
}
|
||||
|
||||
// blocking unwanted pop-ups
|
||||
if (e.message.type === 'popup') {
|
||||
if (typeof vAPI.tabs.onPopup === 'function') {
|
||||
|
@ -769,6 +774,20 @@ if (window.chrome) {
|
|||
safari.application.addEventListener('beforeNavigate', function(e) {
|
||||
// e.url is not present for local files or data URIs
|
||||
if (e.url) {
|
||||
// beforeNavigate fires twice when opening a link with
|
||||
// middle click. Once with the same tab, second time with
|
||||
// the new tab. This hack tries to ignore the first one.
|
||||
if (vAPI.lastMiddleClick) {
|
||||
if (e.target === safari.application.activeBrowserWindow.activeTab
|
||||
&& e.timeStamp - vAPI.lastMiddleClick.timeStamp <= 500
|
||||
&& e.url === vAPI.lastMiddleClick.middleClickURL) {
|
||||
vAPI.lastMiddleClick = null;
|
||||
return;
|
||||
}
|
||||
|
||||
vAPI.lastMiddleClick = null;
|
||||
}
|
||||
|
||||
vAPI.net.onBeforeRequest.callback({
|
||||
name: 'canLoad',
|
||||
target: e.target,
|
||||
|
|
|
@ -187,6 +187,9 @@ if (window.chrome) {
|
|||
return;
|
||||
}
|
||||
|
||||
var beforeLoadEvent = document.createEvent('Event');
|
||||
beforeLoadEvent.initEvent('beforeload');
|
||||
|
||||
var linkHelper = document.createElement('a');
|
||||
var onBeforeLoad = function(e, details) {
|
||||
if (e.url && e.url.slice(0, 5) === 'data:') {
|
||||
|
@ -274,8 +277,6 @@ if (window.chrome) {
|
|||
document.removeEventListener('DOMSubtreeModified', firstMutation, true);
|
||||
firstMutation = null;
|
||||
var randomEventName = parseInt(Math.random() * 1e15, 10).toString(36);
|
||||
var beforeLoadEvent = document.createEvent('Event');
|
||||
beforeLoadEvent.initEvent('beforeload');
|
||||
|
||||
window.addEventListener(randomEventName, function(e) {
|
||||
var result = onBeforeLoad(beforeLoadEvent, e.detail);
|
||||
|
@ -342,6 +343,21 @@ if (window.chrome) {
|
|||
};
|
||||
|
||||
window.addEventListener('contextmenu', onContextMenu, true);
|
||||
|
||||
window.addEventListener('mouseup', function(e) {
|
||||
if (e.button !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = document.evaluate('ancestor-or-self::a[@href]', e.target, null, 9, null).singleNodeValue;
|
||||
|
||||
if (e && /^https?:$/.test(e.protocol)) {
|
||||
safari.self.tab.canLoad(beforeLoadEvent, {
|
||||
middleClickURL: e.href,
|
||||
timeStamp: Date.now()
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue