1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-18 08:52:26 +02:00

Allow creating broad cosmetic filters directly from the picker

Using the Ctrl key while cliking an element on the page will cause
the picker to choose a broad cosmetic filter as candidate.
This commit is contained in:
Raymond Hill 2018-12-22 15:44:23 -05:00
parent d574a09784
commit 91144c4edc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1217,7 +1217,7 @@ var removeAllChildren = function(parent) {
// TODO: for convenience I could provide a small set of net filters instead
// of just a single one. Truncating the right-most part of the path etc.
var showDialog = function(options) {
const showDialog = function(options) {
pausePicker();
options = options || {};
@ -1228,7 +1228,7 @@ var showDialog = function(options) {
dialog.classList.remove('hide');
// Create lists of candidate filters
var populate = function(src, des) {
const populate = function(src, des) {
var root = dialog.querySelector(des);
var ul = root.querySelector('ul');
removeAllChildren(ul);
@ -1257,7 +1257,7 @@ var showDialog = function(options) {
return;
}
var filterChoice = {
const filterChoice = {
filters: bestCandidateFilter.filters,
slot: bestCandidateFilter.slot,
modifier: options.modifier || false
@ -1269,10 +1269,10 @@ var showDialog = function(options) {
/******************************************************************************/
var zap = function() {
const zap = function() {
if ( targetElements.length === 0 ) { return; }
var elem = targetElements[0],
style = window.getComputedStyle(elem);
let elem = targetElements[0];
const style = window.getComputedStyle(elem);
// Heuristic to detect scroll-locking: remove such lock when detected.
if ( parseInt(style.zIndex, 10) >= 1000 || style.position === 'fixed' ) {
document.body.style.setProperty('overflow', 'auto', 'important');
@ -1433,7 +1433,10 @@ var onSvgClicked = function(ev) {
if ( filtersFrom(ev.clientX, ev.clientY) === 0 ) {
return;
}
showDialog({ show: ev.type === 'touch' });
showDialog({
show: ev.type === 'touch',
modifier: ev.ctrlKey
});
};
/******************************************************************************/