diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 62a3d4fd..6f608a8b 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -315,55 +315,6 @@
"message": "Enable",
"description": "Label for the button to enable a style"
},
- "excludedDomain": {
- "message": "Domain",
- "description": "Label for a domain or subdomain portion of an URL used to exclude a style"
- },
- "excludedPrefix": {
- "message": "Prefix",
- "description": "Label for a full url with a subdirectory to be used as the beginning portion of a URL to match to exclude a style"
- },
- "exclusionsAddTitle": {
- "message": "Add exclusion",
- "description": "Title of popup to add an excluded site or page (URL)"
- },
- "exclusionsHeader": {
- "message": "Excluded",
- "description": "Title of user configurable lists of site urls to exclude per style"
- },
- "exclusionsHelp": {
- "message": "Exclusion entries are only checked when a style is set to be applied to a page, and if an exclusion is found, the given style (and all internal sections) will not be applied to that page.\n\nThe list of exclusions is set separately from the userstyle so that it will not be effected when updating or editing the style itself. This is useful because you can exclude pages that would be otherwise be effected by a global style.\n\nAdd one or more exclusion entries for each style. An exclusion entry string contains a pattern that will match a web location (URL). This string may contain wildcards (\"*\") to match any portion of a URL, e.g. \"forum.*.com\" will exclude the forum sub-domains of all top level dot-com domains. Regular expressions are allowed, except `.` and `*` are altered, and are saved as a string so character classes must be doubly escaped (e.g. `\\\\w`).\n\nExcluded pages are automatically updated while typing; invalid entries will be removed on page reload!",
- "description": "Help text for user set style exclusions"
- },
- "exclusionsHelpTitle": {
- "message": "Set Style Exclusions",
- "description": "Header text for help modal"
- },
- "exclusionsvalidateEntry": {
- "message": "Enter a unique and valid URL",
- "description": "Text for an alert notifying the user that an entered URL is not unique or invalid"
- },
- "exclusionsPopupTitle": {
- "message": "Exclude the site or page",
- "description": "Title of exclusion popup dialog within the extension popup"
- },
- "exclusionsPopupTip": {
- "message": "Right-click to edit exclusions on this page",
- "description": "Title on the checkbox in the popup to let the user know how to edit exclusions on the current page"
- },
- "exclusionsPrefix": {
- "message": "Excluded on: ",
- "description": "Prefix label added to the applies to column in the style manager"
- },
- "exclusionsStatus": {
- "message": "$number$ pages",
- "description": "Label added next to the Excluded Pages header when 'number' is not zero",
- "placeholders": {
- "number": {
- "content": "$1"
- }
- }
- },
"exportLabel": {
"message": "Export",
"description": "Label for the button to export a style ('edit' page) or all styles ('manage' page)"
diff --git a/edit.html b/edit.html
index 6b7ae8b8..7b7a10dd 100644
--- a/edit.html
+++ b/edit.html
@@ -88,7 +88,6 @@
-
@@ -200,16 +199,6 @@
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
:
@@ -518,10 +497,6 @@
-
-
-
-
@@ -182,18 +181,6 @@
-
-
-
Style's Name
-
-
-
-
-
-
-
-
-
diff --git a/popup/popup-exclusions.js b/popup/popup-exclusions.js
deleted file mode 100644
index 90be8f40..00000000
--- a/popup/popup-exclusions.js
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-global messageBox t $create getActiveTab tryRegExp animateElement $ API
-*/
-'use strict';
-
-/* exported popupExclusions */
-const popupExclusions = (() => {
-
- // return matches on url ending to prevent duplicates in the exclusion list
- // e.g. http://test.com and http://test.com/* are equivalent
- // this function would return ['', '/*']
- function exclusionExists(array, value) {
- const match = [];
- ['', '*', '/', '/*'].forEach(ending => {
- if (array.includes(value + ending)) {
- match.push(ending);
- }
- });
- return match;
- }
-
- /* Modal in Popup.html */
- function processURL(url) {
- const results = [];
- const protocol = url.match(/\w+:\/\//);
- // remove ending '/', protocol, hash & search strings
- const parts = url.replace(/\/$/, '').replace(/(\w+:\/\/|[#?].*$)/g, '').split('/');
- const domain = parts[0].split('.');
- /*
- Domain: a.b.com
- Domain: b.com
- Prefix: https://a.b.com
- Prefix: https://a.b.com/current
- Prefix: https://a.b.com/current/page
- */
- while (parts.length > 1) {
- results.push([t('excludedPrefix'), protocol + parts.join('/')]);
- parts.pop();
- }
- while (domain.length > 1) {
- results.push([t('excludedDomain'), domain.join('.')]);
- domain.shift();
- }
- return results.reverse();
- }
-
- function shortenURL(text) {
- const len = text.length;
- let prefix = '\u2026';
- // account for URL that end with a '/'
- let index = (text.endsWith('/') ? text.substring(0, len - 1) : text).lastIndexOf('/');
- if (index < 0 || len - index < 2) {
- index = 0;
- prefix = '';
- }
- return prefix + text.substring(index, len);
- }
-
- function createOption(option) {
- // ["Domain/Prefix", "{url}"]
- return $create('option', {
- value: option[1],
- title: option[1],
- textContent: `${option[0]}: ${shortenURL(option[1])}`
- });
- }
-
- function getMultiOptions({select, selectedOnly} = {}) {
- return [...select.children].reduce((acc, opt) => {
- if (selectedOnly && opt.selected || !selectedOnly) {
- acc.push(opt.value);
- }
- return acc;
- }, []);
- }
-
- function updatePopupContent(url) {
- const options = processURL(url);
- const renderBin = document.createDocumentFragment();
- options.map(option => renderBin.appendChild(createOption(option)));
- $('#popup-exclusions').textContent = '';
- $('#popup-exclusions').appendChild(renderBin);
- }
-
- function getIframeURLs(style) {
- getActiveTab().then(tab => {
- if (tab && tab.status === 'complete') {
- chrome.webNavigation.getAllFrames({
- tabId: tab.id
- }, frames => {
- const urls = frames.reduce((acc, frame) => [...acc, ...processURL(frame.url)], []);
- updateSelections(style, urls);
- });
- }
- });
- }
-
- function selectExclusions(exclusions) {
- const select = $('#exclude select');
- const excludes = Object.keys(exclusions || {});
- [...select.children].forEach(option => {
- if (exclusionExists(excludes, option.value).length) {
- option.selected = true;
- }
- });
- }
-
- function updateSelections(style, newOptions = []) {
- const wrap = $('#exclude');
- const select = $('select', wrap);
- if (newOptions.length) {
- const currentOptions = [...select.children].map(opt => opt.value);
- newOptions.forEach(opt => {
- if (!currentOptions.includes(opt[1])) {
- select.appendChild(createOption(opt));
- // newOptions may have duplicates (e.g. multiple iframes from same source)
- currentOptions.push(opt[1]);
- }
- });
- select.size = select.children.length;
- // hide select, then calculate & adjust height
- select.style.height = '0';
- document.body.style.height = `${select.scrollHeight + wrap.offsetHeight}px`;
- select.style.height = '';
- }
- selectExclusions(style.exclusions);
- }
-
- function isExcluded(matchUrl, exclusions = {}) {
- const values = Object.values(exclusions);
- return values.length && values.some(exclude => tryRegExp(exclude).test(matchUrl));
- }
-
- function openPopupDialog(entry, tabURL) {
- const style = entry.styleMeta;
- updateSelections(style, updatePopupContent(tabURL));
- getIframeURLs(style);
- const box = $('#exclude');
- box.dataset.display = true;
- box.style.cssText = '';
- $('strong', box).textContent = style.name;
- $('[data-cmd="ok"]', box).focus();
- $('[data-cmd="ok"]', box).onclick = () => confirm(true);
- $('[data-cmd="cancel"]', box).onclick = () => confirm(false);
- window.onkeydown = event => {
- const keyCode = event.keyCode || event.which;
- if (!event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey
- && (keyCode === 13 || keyCode === 27)) {
- event.preventDefault();
- confirm(keyCode === 13);
- }
- };
- function confirm(ok) {
- window.onkeydown = null;
- animateElement(box, {
- className: 'lights-on',
- onComplete: () => (box.dataset.display = false),
- });
- document.body.style.height = '';
- const excluded = isExcluded(tabURL, style.exclusions);
- if (ok) {
- handlePopupSave(style);
- entry.styleMeta = style;
- entry.classList.toggle('excluded', excluded);
- }
- }
- return Promise.resolve();
- }
-
- function handlePopupSave(style) {
- if (!Array.isArray(style.exclusions)) {
- style.exclusions = [];
- }
- const current = new Set(style.exclusions);
- const select = $('#popup-exclusions', messageBox.element);
- const all = getMultiOptions({select});
- const selected = new Set(getMultiOptions({select, selectedOnly: true}));
- for (const value of all) {
- if (current.has(value) && !selected.has(value)) {
- const index = style.exclusions.indexOf(value);
- style.exclusions.splice(index, 1);
- }
- if (!current.has(value) && selected.has(value)) {
- style.exclusions.push(value);
- }
- }
- API.setStyleExclusions(style.id, style.exclusions);
- }
-
- return {openPopupDialog, selectExclusions, isExcluded};
-})();
diff --git a/popup/popup.css b/popup/popup.css
index 22e8f73d..ddefc44b 100644
--- a/popup/popup.css
+++ b/popup/popup.css
@@ -89,6 +89,7 @@ body > div:not(#installed):not(#message-box):not(.colorpicker-popup) {
position: absolute;
top: 7px;
left: var(--outer-padding);
+ pointer-events: none;
}
#disable-all-wrapper {
@@ -117,21 +118,6 @@ body > div:not(#installed):not(#message-box):not(.colorpicker-popup) {
margin-right: .5em;
}
-#popup-exclusions-title {
- margin: 2px;
-}
-
-#popup-exclusions {
- height: auto;
- overflow-y: auto;
- max-width: 98%;
- padding: 0 2px;
-}
-
-#popup-exclusions option {
- overflow: hidden;
-}
-
.checker {
display: inline;
}
@@ -249,10 +235,6 @@ html[style] .entry {
padding-right: 5px;
}
-.entry.excluded .style-name {
- color: #d22;
-}
-
.entry:nth-child(even) {
background-color: rgba(0, 0, 0, 0.05);
}
@@ -504,7 +486,7 @@ body.blocked .actions > .main-controls {
/* confirm */
-#confirm, #exclude {
+#confirm {
align-items: center;
justify-content: center;
z-index: 2147483647;
@@ -521,26 +503,21 @@ body.blocked .actions > .main-controls {
animation-fill-mode: both;
}
-#confirm.lights-on,
-#exclude.lights-on {
+#confirm.lights-on {
animation: lights-on .25s ease-in-out;
animation-fill-mode: both;
}
#confirm.lights-on,
-#confirm.lights-on > div,
-#exclude.lights-on,
-#exclude.lights-on > div {
+#confirm.lights-on > div {
display: none;
}
-#confirm[data-display=true],
-#exclude[data-display=true] {
+#confirm[data-display=true] {
display: flex;
}
-#confirm > div,
-#exclude > div {
+#confirm > div {
width: 80%;
max-height: 80%;
min-height: 6em;
@@ -555,23 +532,16 @@ body.blocked .actions > .main-controls {
padding-bottom: .5em;
}
-#exclude select {
- margin: .5em 0;
-}
-
-#confirm > div > div,
-#exclude > div > div {
+#confirm > div > div {
text-align: center;
}
-.non-windows #confirm > div > div,
-.non-windows #exclude > div > div {
+.non-windows #confirm > div > div {
direction: rtl;
text-align: right;
}
-#confirm > button,
-#exclude > button {
+#confirm > button {
/* add a gap between buttons both for horizontal
or vertical (when the label is wide) layout */
margin: 0 .25em .25em 0;
diff --git a/popup/popup.js b/popup/popup.js
index 99877b42..1b619d30 100644
--- a/popup/popup.js
+++ b/popup/popup.js
@@ -51,7 +51,6 @@ function onRuntimeMessage(msg) {
switch (msg.method) {
case 'styleAdded':
case 'styleUpdated':
- case 'exclusionsUpdated':
if (msg.reason === 'editPreview' || msg.reason === 'editPreviewEnd') return;
handleUpdate(msg);
break;
@@ -258,9 +257,9 @@ function createStyleElement({
const checkbox = $('.checker', entry);
Object.assign(checkbox, {
id: ENTRY_ID_PREFIX_RAW + style.id,
- title: t('exclusionsPopupTip'),
+ // title: t('exclusionsPopupTip'),
onclick: handleEvent.toggle,
- oncontextmenu: handleEvent.openExcludeMenu
+ // oncontextmenu: handleEvent.openExcludeMenu
});
const editLink = $('.style-edit-link', entry);
Object.assign(editLink, {
@@ -294,15 +293,9 @@ function createStyleElement({
style = Object.assign(entry.styleMeta, style);
- if (style.enabled) {
- entry.classList.remove('disabled');
- entry.classList.add('enabled');
- $('.checker', entry).checked = true;
- } else {
- entry.classList.add('disabled');
- entry.classList.remove('enabled');
- $('.checker', entry).checked = false;
- }
+ entry.classList.toggle('disabled', !style.enabled);
+ entry.classList.toggle('enabled', style.enabled);
+ $('.checker', entry).checked = style.enabled;
const styleName = $('.style-name', entry);
styleName.lastChild.textContent = style.name;
@@ -324,7 +317,6 @@ function createStyleElement({
style.usercssData && Object.keys(style.usercssData.vars || {}).length ?
'' : 'none';
- // entry.classList.toggle('excluded', style.excluded);
entry.classList.toggle('not-applied', style.excluded || style.sloppy);
entry.classList.toggle('regexp-partial', style.sloppy);
@@ -434,12 +426,6 @@ Object.assign(handleEvent, {
event.button === 2)) {
return;
}
- // open exclude page config dialog on right-click
- if (event.target.classList.contains('checker')) {
- this.oncontextmenu = handleEvent.openExcludeMenu;
- event.preventDefault();
- return;
- }
// open an editor on middleclick
if (event.target.matches('.entry, .style-name, .style-edit-link')) {
this.onmouseup = () => $('.style-edit-link', this).click();
@@ -481,21 +467,6 @@ Object.assign(handleEvent, {
handleEvent.openURLandHide.call(this, event);
}
},
-
- openExcludeMenu(event) {
- event.preventDefault();
- event.stopPropagation();
- const chkbox = this;
- const entry = event.target.closest('.entry');
- if (!chkbox.eventHandled) {
- chkbox.eventHandled = true;
- popupExclusions
- .openPopupDialog(entry, tabURL)
- .then(() => {
- chkbox.eventHandled = null;
- });
- }
- }
});