mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
this fixes #507
This commit is contained in:
parent
f1cf2036fc
commit
528354f594
@ -294,6 +294,7 @@ vAPI.tabs.open = function(details) {
|
|||||||
if ( typeof targetURL !== 'string' || targetURL === '' ) {
|
if ( typeof targetURL !== 'string' || targetURL === '' ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extension pages
|
// extension pages
|
||||||
if ( /^[\w-]{2,}:/.test(targetURL) !== true ) {
|
if ( /^[\w-]{2,}:/.test(targetURL) !== true ) {
|
||||||
targetURL = vAPI.getURL(targetURL);
|
targetURL = vAPI.getURL(targetURL);
|
||||||
@ -370,15 +371,33 @@ vAPI.tabs.open = function(details) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.tabs.query({ url: targetURL }, function(tabs) {
|
// https://developer.chrome.com/extensions/tabs#method-query
|
||||||
|
// "Note that fragment identifiers are not matched."
|
||||||
|
// It's a lie, fragment identifiers ARE matched. So we need to remove the
|
||||||
|
// fragment.
|
||||||
|
var targetURLWithoutHash = targetURL;
|
||||||
|
var pos = targetURL.indexOf('#');
|
||||||
|
if ( pos !== -1 ) {
|
||||||
|
targetURLWithoutHash = targetURL.slice(0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.tabs.query({ url: targetURLWithoutHash }, function(tabs) {
|
||||||
var tab = tabs[0];
|
var tab = tabs[0];
|
||||||
if ( tab ) {
|
if ( !tab ) {
|
||||||
chrome.tabs.update(tab.id, { active: true }, function(tab) {
|
wrapper();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _details = {
|
||||||
|
active: true,
|
||||||
|
url: undefined
|
||||||
|
};
|
||||||
|
if ( targetURL !== tab.url ) {
|
||||||
|
_details.url = targetURL;
|
||||||
|
}
|
||||||
|
chrome.tabs.update(tab.id, _details, function(tab) {
|
||||||
chrome.windows.update(tab.windowId, { focused: true });
|
chrome.windows.update(tab.windowId, { focused: true });
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
wrapper();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -669,7 +669,17 @@ vAPI.tabs.open = function(details) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Or simply .equals if we care about the fragment
|
||||||
|
if ( URI.equalsExceptRef(browser.currentURI) === false ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
this.select(tab);
|
this.select(tab);
|
||||||
|
|
||||||
|
// Update URL if fragment is different
|
||||||
|
if ( URI.equals(browser.currentURI) === false ) {
|
||||||
|
browser.loadURI(URI.asciiSpec);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,6 +688,10 @@ var onLogBufferRead = function(response) {
|
|||||||
allTabIdsToken = response.tabIdsToken;
|
allTabIdsToken = response.tabIdsToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/507
|
||||||
|
// Ensure tab selector is in sync with URL hash
|
||||||
|
pageSelectorFromURLHash();
|
||||||
|
|
||||||
renderLogEntries(response);
|
renderLogEntries(response);
|
||||||
|
|
||||||
if ( rowVoided ) {
|
if ( rowVoided ) {
|
||||||
@ -719,8 +723,36 @@ var readLogBuffer = function() {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var pageSelectorChanged = function() {
|
var pageSelectorChanged = function() {
|
||||||
|
window.location.replace('#' + uDom.nodeFromId('pageSelector').value);
|
||||||
|
pageSelectorFromURLHash();
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var pageSelectorFromURLHash = (function() {
|
||||||
|
var lastHash = '';
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
var hash = window.location.hash;
|
||||||
|
if ( hash === lastHash ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tabClass = hash.slice(1);
|
||||||
|
var select = uDom.nodeFromId('pageSelector');
|
||||||
|
var option = select.querySelector('option[value="' + tabClass + '"]');
|
||||||
|
if ( option === null ) {
|
||||||
|
hash = window.location.hash = '';
|
||||||
|
tabClass = '';
|
||||||
|
option = select.options[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
lastHash = hash;
|
||||||
|
|
||||||
|
select.selectedIndex = option.index;
|
||||||
|
select.value = option.value;
|
||||||
|
|
||||||
var style = uDom.nodeFromId('tabFilterer');
|
var style = uDom.nodeFromId('tabFilterer');
|
||||||
var tabClass = uDom.nodeFromId('pageSelector').value;
|
|
||||||
var sheet = style.sheet;
|
var sheet = style.sheet;
|
||||||
while ( sheet.cssRules.length !== 0 ) {
|
while ( sheet.cssRules.length !== 0 ) {
|
||||||
sheet.deleteRule(0);
|
sheet.deleteRule(0);
|
||||||
@ -736,6 +768,7 @@ var pageSelectorChanged = function() {
|
|||||||
tabClass === '' || tabClass === 'tab_bts'
|
tabClass === '' || tabClass === 'tab_bts'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -1720,7 +1753,6 @@ var popupManager = (function() {
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
uDom.onLoad(function() {
|
|
||||||
readLogBuffer();
|
readLogBuffer();
|
||||||
|
|
||||||
uDom('#pageSelector').on('change', pageSelectorChanged);
|
uDom('#pageSelector').on('change', pageSelectorChanged);
|
||||||
@ -1735,10 +1767,7 @@ uDom.onLoad(function() {
|
|||||||
uDom('#netInspector').on('click', 'tr.canLookup > td:nth-of-type(3)', reverseLookupManager.toggleOn);
|
uDom('#netInspector').on('click', 'tr.canLookup > td:nth-of-type(3)', reverseLookupManager.toggleOn);
|
||||||
uDom('#netInspector').on('click', 'tr.cat_net > td:nth-of-type(4)', netFilteringManager.toggleOn);
|
uDom('#netInspector').on('click', 'tr.cat_net > td:nth-of-type(4)', netFilteringManager.toggleOn);
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/404
|
window.addEventListener('hashchange', pageSelectorFromURLHash);
|
||||||
// Ensure page state is in sync with the state of its various widgets.
|
|
||||||
pageSelectorChanged();
|
|
||||||
});
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -433,6 +433,15 @@ var renderPopup = function() {
|
|||||||
}
|
}
|
||||||
uDom.nodeFromId('total-blocked').textContent = text;
|
uDom.nodeFromId('total-blocked').textContent = text;
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/507
|
||||||
|
// Convenience: open the logger with current tab automatically selected
|
||||||
|
if ( popupData.tabId ) {
|
||||||
|
uDom.nodeFromSelector('.statName > a[href^="logger-ui.html"]').setAttribute(
|
||||||
|
'href',
|
||||||
|
'logger-ui.html#tab_' + popupData.tabId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// This will collate all domains, touched or not
|
// This will collate all domains, touched or not
|
||||||
renderPrivacyExposure();
|
renderPrivacyExposure();
|
||||||
|
|
||||||
@ -825,9 +834,9 @@ var onHideTooltip = function() {
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// Make menu only when popup html is fully loaded
|
// Popup DOM is assumed to be loaded at this point -- because this script
|
||||||
|
// is loaded after everything else..
|
||||||
|
|
||||||
uDom.onLoad(function () {
|
|
||||||
// If there's no tab id specified in the query string,
|
// If there's no tab id specified in the query string,
|
||||||
// it will default to current tab.
|
// it will default to current tab.
|
||||||
var tabId = null;
|
var tabId = null;
|
||||||
@ -851,7 +860,6 @@ uDom.onLoad(function () {
|
|||||||
|
|
||||||
uDom('body').on('mouseenter', '[data-tip]', onShowTooltip)
|
uDom('body').on('mouseenter', '[data-tip]', onShowTooltip)
|
||||||
.on('mouseleave', '[data-tip]', onHideTooltip);
|
.on('mouseleave', '[data-tip]', onHideTooltip);
|
||||||
});
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user