| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 { | 82 { |
| 83 let access = (item.url || item.text).replace(/'/g, "\\'"); | 83 let access = (item.url || item.text).replace(/'/g, "\\'"); |
| 84 return function(container) | 84 return function(container) |
| 85 { | 85 { |
| 86 return container.querySelector("[data-access='" + access + "']"); | 86 return container.querySelector("[data-access='" + access + "']"); |
| 87 }; | 87 }; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 Collection.prototype._getItemTitle = function(item, i) | 90 Collection.prototype._getItemTitle = function(item, i) |
| 91 { | 91 { |
| 92 if (this.details[i].useSpecialization && item.specialization) | 92 if (this.details[i].getTitleFunction) |
| 93 return item.specialization; | 93 return this.details[i].getTitleFunction(item); |
| 94 if (this.details[i].useOriginalTitle && item.originalTitle) | |
| 95 return item.originalTitle; | |
| 96 return item.title || item.url || item.text; | 94 return item.title || item.url || item.text; |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 Collection.prototype._sortItems = function() | 97 Collection.prototype._sortItems = function() |
| 100 { | 98 { |
| 101 this.items.sort((a, b) => | 99 this.items.sort((a, b) => |
| 102 { | 100 { |
| 103 // Make sure that Acceptable Ads is always last, since it cannot be | 101 // Make sure that Acceptable Ads is always last, since it cannot be |
| 104 // disabled, but only be removed. That way it's grouped together with | 102 // disabled, but only be removed. That way it's grouped together with |
| 105 // the "Own filter list" which cannot be disabled either at the bottom | 103 // the "Own filter list" which cannot be disabled either at the bottom |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 this._sortItems(); | 214 this._sortItems(); |
| 217 let access = (item.url || item.text).replace(/'/g, "\\'"); | 215 let access = (item.url || item.text).replace(/'/g, "\\'"); |
| 218 for (let i = 0; i < this.details.length; i++) | 216 for (let i = 0; i < this.details.length; i++) |
| 219 { | 217 { |
| 220 let table = E(this.details[i].id); | 218 let table = E(this.details[i].id); |
| 221 let element = table.querySelector("[data-access='" + access + "']"); | 219 let element = table.querySelector("[data-access='" + access + "']"); |
| 222 if (!element) | 220 if (!element) |
| 223 continue; | 221 continue; |
| 224 | 222 |
| 225 let title = this._getItemTitle(item, i); | 223 let title = this._getItemTitle(item, i); |
| 226 let displays = element.querySelectorAll(".display"); | 224 let displays = element.querySelectorAll("[data-display]"); |
| 227 for (let j = 0; j < displays.length; j++) | 225 for (let j = 0; j < displays.length; j++) |
| 228 displays[j].textContent = title; | 226 { |
| 227 if (item[displays[j].dataset.display]) |
| 228 displays[j].textContent = item[displays[j].dataset.display]; |
| 229 else |
| 230 displays[j].textContent = title; |
| 231 } |
| 229 | 232 |
| 230 element.setAttribute("aria-label", title); | 233 element.setAttribute("aria-label", title); |
| 231 if (this.details[i].searchable) | 234 if (this.details[i].searchable) |
| 232 element.setAttribute("data-search", title.toLowerCase()); | 235 element.setAttribute("data-search", title.toLowerCase()); |
| 233 let controls = element.querySelectorAll(".control[role='checkbox']"); | 236 let controls = element.querySelectorAll(".control[role='checkbox']"); |
| 234 for (let control of controls) | 237 for (let control of controls) |
| 235 { | 238 { |
| 236 control.setAttribute("aria-checked", item.disabled == false); | 239 control.setAttribute("aria-checked", item.disabled == false); |
| 237 if (isAcceptableAds(item.url) && this == collections.filterLists) | 240 if (isAcceptableAds(item.url) && this == collections.filterLists) |
| 238 control.disabled = true; | 241 control.disabled = true; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 347 |
| 345 collections.protection = new Collection([ | 348 collections.protection = new Collection([ |
| 346 { | 349 { |
| 347 id: "recommend-protection-list-table" | 350 id: "recommend-protection-list-table" |
| 348 } | 351 } |
| 349 ]); | 352 ]); |
| 350 collections.langs = new Collection([ | 353 collections.langs = new Collection([ |
| 351 { | 354 { |
| 352 id: "blocking-languages-table", | 355 id: "blocking-languages-table", |
| 353 emptyTexts: ["options_language_empty"], | 356 emptyTexts: ["options_language_empty"], |
| 354 useSpecialization: true | 357 getTitleFunction: getLanguageTitle |
| 355 } | 358 } |
| 356 ]); | 359 ]); |
| 357 collections.allLangs = new Collection([ | 360 collections.allLangs = new Collection([ |
| 358 { | 361 { |
| 359 id: "all-lang-table-add", | 362 id: "all-lang-table-add", |
| 360 emptyTexts: ["options_dialog_language_other_empty"], | 363 emptyTexts: ["options_dialog_language_other_empty"], |
| 361 useSpecialization: true | 364 getTitleFunction: getLanguageTitle |
| 362 } | 365 } |
| 363 ]); | 366 ]); |
| 364 collections.more = new Collection([ | 367 collections.more = new Collection([ |
| 365 { | 368 { |
| 366 id: "more-list-table", | 369 id: "more-list-table", |
| 367 setEmptyAction: "hide-more-filters-section", | 370 setEmptyAction: "hide-more-filters-section", |
| 368 removeEmptyAction: "show-more-filters-section" | 371 removeEmptyAction: "show-more-filters-section" |
| 369 } | 372 } |
| 370 ]); | 373 ]); |
| 371 collections.whitelist = new Collection([ | 374 collections.whitelist = new Collection([ |
| 372 { | 375 { |
| 373 id: "whitelisting-table", | 376 id: "whitelisting-table", |
| 374 emptyTexts: ["options_whitelist_empty_1", "options_whitelist_empty_2"] | 377 emptyTexts: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
| 375 } | 378 } |
| 376 ]); | 379 ]); |
| 377 collections.filterLists = new Collection([ | 380 collections.filterLists = new Collection([ |
| 378 { | 381 { |
| 379 id: "all-filter-lists-table", | 382 id: "all-filter-lists-table", |
| 380 emptyTexts: ["options_filterList_empty"], | 383 emptyTexts: ["options_filterList_empty"] |
| 381 useOriginalTitle: true | |
| 382 } | 384 } |
| 383 ]); | 385 ]); |
| 384 | 386 |
| 385 function addSubscription(subscription) | 387 function addSubscription(subscription) |
| 386 { | 388 { |
| 387 let {disabled} = subscription; | 389 let {disabled} = subscription; |
| 388 let collection = null; | 390 let collection = null; |
| 389 if (subscription.recommended) | 391 if (subscription.recommended) |
| 390 { | 392 { |
| 391 if (subscription.recommended == "ads") | 393 if (subscription.recommended == "ads") |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 480 |
| 479 updateCustomFiltersUi(); | 481 updateCustomFiltersUi(); |
| 480 } | 482 } |
| 481 | 483 |
| 482 function updateCustomFiltersUi() | 484 function updateCustomFiltersUi() |
| 483 { | 485 { |
| 484 let customFiltersListElement = E("custom-filters-raw"); | 486 let customFiltersListElement = E("custom-filters-raw"); |
| 485 customFiltersListElement.value = customFilters.join("\n"); | 487 customFiltersListElement.value = customFilters.join("\n"); |
| 486 } | 488 } |
| 487 | 489 |
| 490 function getLanguageTitle(item) |
| 491 { |
| 492 let title = item.specialization; |
| 493 if (item.originalTitle && item.originalTitle.indexOf("+EasyList") > -1) |
| 494 title += " + " + getMessage("options_english"); |
| 495 return title; |
| 496 } |
| 497 |
| 488 function loadRecommendations() | 498 function loadRecommendations() |
| 489 { | 499 { |
| 490 fetch("subscriptions.xml") | 500 fetch("subscriptions.xml") |
| 491 .then((response) => | 501 .then((response) => |
| 492 { | 502 { |
| 493 return response.text(); | 503 return response.text(); |
| 494 }) | 504 }) |
| 495 .then((text) => | 505 .then((text) => |
| 496 { | 506 { |
| 497 let doc = new DOMParser().parseFromString(text, "application/xml"); | 507 let doc = new DOMParser().parseFromString(text, "application/xml"); |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 }); | 1469 }); |
| 1460 browser.runtime.sendMessage({ | 1470 browser.runtime.sendMessage({ |
| 1461 type: "subscriptions.listen", | 1471 type: "subscriptions.listen", |
| 1462 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1472 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1463 "title", "downloadStatus", "downloading"] | 1473 "title", "downloadStatus", "downloading"] |
| 1464 }); | 1474 }); |
| 1465 | 1475 |
| 1466 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1476 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1467 window.addEventListener("hashchange", onHashChange, false); | 1477 window.addEventListener("hashchange", onHashChange, false); |
| 1468 } | 1478 } |
| OLD | NEW |