mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
this fixes #1511 (point 2)
This commit is contained in:
parent
54176612fd
commit
62b087ef88
@ -1133,6 +1133,17 @@ var netFilteringManager = (function() {
|
|||||||
container.appendChild(preview);
|
container.appendChild(preview);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/1511
|
||||||
|
var shortenLongString = function(url, max) {
|
||||||
|
var urlLen = url.length;
|
||||||
|
if ( urlLen <= max ) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
var n = urlLen - max - 1;
|
||||||
|
var i = (urlLen - n) / 2 | 0;
|
||||||
|
return url.slice(0, i) + '…' + url.slice(i + n);
|
||||||
|
};
|
||||||
|
|
||||||
// Build list of candidate URLs
|
// Build list of candidate URLs
|
||||||
var createTargetURLs = function(url) {
|
var createTargetURLs = function(url) {
|
||||||
var urls = [];
|
var urls = [];
|
||||||
@ -1185,7 +1196,7 @@ var netFilteringManager = (function() {
|
|||||||
url = targetURLs[i];
|
url = targetURLs[i];
|
||||||
menuEntry = menuEntryTemplate.cloneNode(true);
|
menuEntry = menuEntryTemplate.cloneNode(true);
|
||||||
menuEntry.cells[0].children[0].setAttribute('data-url', url);
|
menuEntry.cells[0].children[0].setAttribute('data-url', url);
|
||||||
menuEntry.cells[1].textContent = url;
|
menuEntry.cells[1].textContent = shortenLongString(url, 128);
|
||||||
tbody.appendChild(menuEntry);
|
tbody.appendChild(menuEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1268,7 +1279,7 @@ var netFilteringManager = (function() {
|
|||||||
value = targetURLs[i].replace(/^[a-z]+:\/\//, '');
|
value = targetURLs[i].replace(/^[a-z]+:\/\//, '');
|
||||||
option = document.createElement('option');
|
option = document.createElement('option');
|
||||||
option.setAttribute('value', value);
|
option.setAttribute('value', value);
|
||||||
option.textContent = value;
|
option.textContent = shortenLongString(value, 128);
|
||||||
select.appendChild(option);
|
select.appendChild(option);
|
||||||
}
|
}
|
||||||
nodes.push(select);
|
nodes.push(select);
|
||||||
|
Loading…
Reference in New Issue
Block a user