| Index: desktop-options.js |
| =================================================================== |
| --- a/desktop-options.js |
| +++ b/desktop-options.js |
| @@ -547,14 +547,15 @@ |
| return null; |
| } |
| - function sendMessageHandleErrors(message, onSuccess) |
| + function sendMessageHandleErrors(message, onMessage) |
| { |
| browser.runtime.sendMessage(message, (errors) => |
| { |
| - if (errors.length > 0) |
| - alert(errors.join("\n")); |
| - else if (onSuccess) |
| - onSuccess(); |
| + if (onMessage) |
| + { |
| + if (errors.length > 0) onMessage(errors); |
| + else onMessage(); |
| + } |
| }); |
| } |
| @@ -648,14 +649,29 @@ |
| }); |
| break; |
| case "save-custom-filters": |
| + const filters = E("custom-filters-raw"); |
| sendMessageHandleErrors({ |
| type: "filters.importRaw", |
| - text: E("custom-filters-raw").value, |
| + text: filters.value, |
| removeExisting: true |
| }, |
| - () => |
| + (errors) => |
| { |
| - setCustomFiltersView("read"); |
| + if (errors) |
| + { |
| + filters.classList.add("warning"); |
| + E("custom-filters-edit-error").classList.add("warning"); |
| + E("link-filters-on-edit-error").classList.add("visible"); |
| + const lines = filters.value.split(/\n+/); |
| + const info = errors.map(error => lines[error.lineno - 1]); |
| + const editFilters = E("custom-filters-edit-filters"); |
| + editFilters.textContent = info.join("\n"); |
| + if (errors.length > 5) editFilters.classList.add("many"); |
| + } |
| + else |
| + { |
| + setCustomFiltersView("read"); |
| + } |
| }); |
| break; |
| case "show-more-filters-section": |
| @@ -755,6 +771,12 @@ |
| updateCustomFiltersUi(); |
| if (mode == "read") |
| { |
| + E("custom-filters-raw").classList.remove("warning"); |
| + E("custom-filters-edit-error").classList.remove("warning"); |
| + E("link-filters-on-edit-error").classList.remove("visible"); |
| + const editFilters = E("custom-filters-edit-filters"); |
| + editFilters.textContent = ""; |
| + editFilters.classList.remove("many"); |
| customFiltersElement.disabled = true; |
| if (!customFiltersElement.value) |
| { |
| @@ -918,10 +940,10 @@ |
| { |
| setLinks("enable-acceptable-ads-description", link); |
| }); |
| - setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
| + setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
| [getMessage("common_feature_privacy_title"), |
| - getMessage("options_acceptableAds_ads_label")]); |
| - setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
| + getMessage("options_acceptableAds_ads_label")]); |
| + setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
| [getMessage("options_acceptableAds_privacy_label")]); |
| getDocLink("privacy_friendly_ads", (link) => |
| @@ -964,6 +986,7 @@ |
| getDocLink("filterdoc", (link) => |
| { |
| E("link-filters").setAttribute("href", link); |
| + E("link-filters-on-edit-error").setAttribute("href", link); |
| }); |
| getDocLink("subscriptions", (link) => |
| @@ -1295,7 +1318,7 @@ |
| updateSubscription(subscription); |
| break; |
| case "added": |
| - let {url, recommended} = subscription; |
| + let {url} = subscription; |
| // Handle custom subscription |
| if (/^~user/.test(url)) |
| { |