Commit 8f89a075 authored by Thomas Greiner's avatar Thomas Greiner

Issue #401 - Adapted code to work with subscriptions.json

parent 621abc96
Pipeline #58218715 (#2010) passed with stages
in 3 minutes and 57 seconds
......@@ -518,12 +518,12 @@ function updateCustomFiltersUi()
function getLanguageTitle(item)
{
const prefixes = item.prefixes.split(",");
const firstPrefix = prefixes.shift();
let title = prefixes.reduce((acc, prefix) =>
const langs = item.languages.slice();
const firstLang = langs.shift();
let title = langs.reduce((acc, lang) =>
{
return getMessage("options_language_join", [acc, languages[prefix]]);
}, languages[firstPrefix]);
return getMessage("options_language_join", [acc, languages[lang]]);
}, languages[firstLang]);
if (item.originalTitle && item.originalTitle.indexOf("+EasyList") > -1)
title += " + " + getMessage("options_english");
return title;
......@@ -533,32 +533,29 @@ function loadRecommendations()
{
return Promise.all([
fetch("data/languages.json").then((resp) => resp.json()),
fetch("subscriptions.xml").then((resp) => resp.text())
]).then(([json, text]) =>
fetch("subscriptions.json").then((resp) => resp.json())
]).then(([languagesData, recommendations]) =>
{
languages = json;
languages = languagesData;
const doc = new DOMParser().parseFromString(text, "application/xml");
const elements = doc.documentElement.getElementsByTagName("subscription");
for (const element of elements)
for (const recommendation of recommendations)
{
let type = element.getAttribute("type");
let {type} = recommendation;
const subscription = {
disabled: true,
downloadStatus: null,
homepage: null,
originalTitle: element.getAttribute("title"),
prefixes: element.getAttribute("prefixes"),
originalTitle: recommendation.title,
languages: recommendation.languages,
recommended: type,
url: element.getAttribute("url")
url: recommendation.url
};
if (subscription.recommended != "ads" &&
subscription.recommended != "circumvention")
{
type = type.replace(/\W/g, "_");
subscription.title = getMessage("common_feature_" +
type + "_title");
subscription.title = getMessage(`common_feature_${type}_title`);
}
addSubscription(subscription);
......
......@@ -86,20 +86,17 @@
function getRecommendedAds()
{
return fetch("subscriptions.xml")
.then((response) => response.text())
.then((text) =>
return fetch("subscriptions.json")
.then((response) => response.json())
.then((recommendations) =>
{
const doc = new DOMParser().parseFromString(text, "application/xml");
const elements = Array.from(doc.getElementsByTagName("subscription"));
return elements
.filter((element) => element.getAttribute("type") == "ads")
.map((element) =>
return recommendations
.filter((recommendation) => recommendation.type == "ads")
.map((recommendation) =>
{
return {
title: element.getAttribute("title"),
url: element.getAttribute("url")
title: recommendation.title,
url: recommendation.url
};
});
});
......
[
{
"type": "ads",
"languages": [
"id",
"ms"
],
"title": "ABPindo+EasyList",
"url": "https://easylist-downloads.adblockplus.org/abpindo+easylist.txt",
"homepage": "http://abpindo.blogspot.com/"
},
{
"type": "ads",
"languages": [
"vi"
],
"title": "ABPVN List+EasyList",
"url": "https://easylist-downloads.adblockplus.org/abpvn+easylist.txt",
"homepage": "http://abpvn.com/"
},
{
"type": "ads",
"languages": [
"bg"
],
"title": "Bulgarian list+EasyList",
"url": "https://easylist-downloads.adblockplus.org/bulgarian_list+easylist.txt",
"homepage": "http://stanev.org/abp/"
},
{
"type": "ads",
"languages": [
"en"
],
"title": "EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"zh"
],
"title": "EasyList China+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt",
"homepage": "http://abpchina.org/forum/"
},
{
"type": "ads",
"languages": [
"cs",
"sk"
],
"title": "EasyList Czech and Slovak+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistczechslovak+easylist.txt",
"homepage": "https://adblock.sk/"
},
{
"type": "ads",
"languages": [
"nl"
],
"title": "EasyList Dutch+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistdutch+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"de"
],
"title": "EasyList Germany+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"he"
],
"title": "EasyList Hebrew+EasyList",
"url": "https://easylist-downloads.adblockplus.org/israellist+easylist.txt",
"homepage": "https://github.com/easylist/EasyListHebrew"
},
{
"type": "ads",
"languages": [
"it"
],
"title": "EasyList Italy+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistitaly+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"lt"
],
"title": "EasyList Lithuania+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistlithuania+easylist.txt",
"homepage": "http://margevicius.lt/"
},
{
"type": "ads",
"languages": [
"pl"
],
"title": "EasyList Polish+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistpolish+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"pt"
],
"title": "EasyList Portuguese+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistportuguese+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"es"
],
"title": "EasyList Spanish+EasyList",
"url": "https://easylist-downloads.adblockplus.org/easylistspanish+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"bn",
"gu",
"hi",
"pa"
],
"title": "IndianList+EasyList",
"url": "https://easylist-downloads.adblockplus.org/indianlist+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"ko"
],
"title": "KoreanList+EasyList",
"url": "https://easylist-downloads.adblockplus.org/koreanlist+easylist.txt",
"homepage": "https://easylist.to/"
},
{
"type": "ads",
"languages": [
"lv"
],
"title": "Latvian List+EasyList",
"url": "https://easylist-downloads.adblockplus.org/latvianlist+easylist.txt",
"homepage": "https://notabug.org/latvian-list/adblock-latvian"
},
{
"type": "ads",
"languages": [
"ar"
],
"title": "Liste AR+Liste FR+EasyList",
"url": "https://easylist-downloads.adblockplus.org/liste_ar+liste_fr+easylist.txt",
"homepage": "https://code.google.com/p/liste-ar-adblock/"
},
{
"type": "ads",
"languages": [
"fr"
],
"title": "Liste FR+EasyList",
"url": "https://easylist-downloads.adblockplus.org/liste_fr+easylist.txt",
"homepage": "https://forums.lanik.us/viewforum.php?f"
},
{
"type": "ads",
"languages": [
"ro"
],
"title": "ROList+EasyList",
"url": "https://easylist-downloads.adblockplus.org/rolist+easylist.txt",
"homepage": "http://www.zoso.ro/rolist"
},
{
"type": "ads",
"languages": [
"ru",
"uk"
],
"title": "RuAdList+EasyList",
"url": "https://easylist-downloads.adblockplus.org/ruadlist+easylist.txt",
"homepage": "https://forums.lanik.us/viewforum.php?f"
},
{
"type": "circumvention",
"title": "ABP filters",
"url": "https://easylist-downloads.adblockplus.org/abp-filters-anti-cv.txt",
"homepage": "https://github.com/abp-filters/abp-filters-anti-cv"
},
{
"type": "privacy",
"title": "EasyPrivacy",
"url": "https://easylist-downloads.adblockplus.org/easyprivacy.txt",
"homepage": "https://easylist.to/"
},
{
"type": "social",
"title": "Fanboy's Social Blocking List",
"url": "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
"homepage": "https://easylist.to/"
}
]
<?xml version="1.0"?>
<!--
- This file is part of the Adblock Plus web scripts,
- Copyright (C) 2006-present eyeo GmbH
-
- Adblock Plus is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 3 as
- published by the Free Software Foundation.
-
- Adblock Plus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
-->
<subscriptions>
<subscription title="EasyList"
specialization="English"
url="https://easylist-downloads.adblockplus.org/easylist.txt"
homepage="https://easylist.to/"
prefixes="en"
author="fanboy, MonztA, Famlam, Khrin"
type="ads"/>
<subscription title="ABPindo+EasyList"
specialization="Bahasa Indonesia"
url="https://easylist-downloads.adblockplus.org/abpindo+easylist.txt"
homepage="http://abpindo.blogspot.com/"
prefixes="id"
author="heradhis"
type="ads"/>
<subscription title="ABPVN List+EasyList"
specialization="Việt"
url="https://easylist-downloads.adblockplus.org/abpvn+easylist.txt"
homepage="http://abpvn.com/"
prefixes="vi"
author="Hoàng Rio"
type="ads"/>
<subscription title="Bulgarian list+EasyList"
specialization="български"
url="https://easylist-downloads.adblockplus.org/bulgarian_list+easylist.txt"
homepage="http://stanev.org/abp/"
prefixes="bg"
author="Александър Станев"
type="ads"/>
<subscription title="EasyList China+EasyList"
specialization="中文"
url="https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"
homepage="http://abpchina.org/forum/"
prefixes="zh"
author="John, Li"
type="ads"/>
<subscription title="EasyList Czech and Slovak+EasyList"
specialization="čeština, slovenčina"
url="https://easylist-downloads.adblockplus.org/easylistczechslovak+easylist.txt"
homepage="https://adblock.sk/"
prefixes="cs,sk"
author="tomasko126"
type="ads"/>
<subscription title="EasyList Dutch+EasyList"
specialization="Nederlands"
url="https://easylist-downloads.adblockplus.org/easylistdutch+easylist.txt"
homepage="https://easylist.to/"
prefixes="nl"
author="Famlam"
type="ads"/>
<subscription title="EasyList Germany+EasyList"
specialization="Deutsch"
url="https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt"
homepage="https://easylist.to/"
prefixes="de"
author="MonztA, Famlam"
type="ads"/>
<subscription title="EasyList Hebrew+EasyList"
specialization="עברית"
url="https://easylist-downloads.adblockplus.org/israellist+easylist.txt"
homepage="https://github.com/easylist/EasyListHebrew"
prefixes="he"
author="BsT"
type="ads"/>
<subscription title="EasyList Italy+EasyList"
specialization="italiano"
url="https://easylist-downloads.adblockplus.org/easylistitaly+easylist.txt"
homepage="https://easylist.to/"
prefixes="it"
author="Khrin"
type="ads"/>
<subscription title="EasyList Lithuania+EasyList"
specialization="lietuvių kalba"
url="https://easylist-downloads.adblockplus.org/easylistlithuania+easylist.txt"
homepage="http://margevicius.lt/"
prefixes="lt"
author="Algimantas Margevičius"
type="ads"/>
<subscription title="EasyList Spanish+EasyList"
specialization="español"
url="https://easylist-downloads.adblockplus.org/easylistspanish+easylist.txt"
homepage="https://easylist.to/"
prefixes="es"
author="diaux"
type="ads"/>
<subscription title="Latvian List+EasyList"
specialization="latviešu valoda"
url="https://easylist-downloads.adblockplus.org/latvianlist+easylist.txt"
homepage="https://notabug.org/latvian-list/adblock-latvian"
prefixes="lv"
author="anonymous74100"
type="ads"/>
<subscription title="Liste AR+Liste FR+EasyList"
specialization="العربية"
url="https://easylist-downloads.adblockplus.org/liste_ar+liste_fr+easylist.txt"
homepage="https://code.google.com/p/liste-ar-adblock/"
prefixes="ar"
author="smed79"
type="ads"/>
<subscription title="Liste FR+EasyList"
specialization="français"
url="https://easylist-downloads.adblockplus.org/liste_fr+easylist.txt"
homepage="https://forums.lanik.us/viewforum.php?f=91"
prefixes="fr"
author="Lian, Crits, smed79"
type="ads"/>
<subscription title="ROList+EasyList"
specialization="românesc"
url="https://easylist-downloads.adblockplus.org/rolist+easylist.txt"
homepage="http://www.zoso.ro/rolist"
prefixes="ro"
author="MenetZ, Zoso"
type="ads"/>
<subscription title="RuAdList+EasyList"
specialization="русский, українська"
url="https://easylist-downloads.adblockplus.org/ruadlist+easylist.txt"
homepage="https://forums.lanik.us/viewforum.php?f=102"
prefixes="ru,uk"
author="Lain_13, dimisa"
type="ads"/>
<subscription title="ABP filters"
specialization="Anti Circumvention, English"
url="https://easylist-downloads.adblockplus.org/abp-filters-anti-cv.txt"
homepage="https://github.com/abp-filters/abp-filters-anti-cv"
prefixes="en"
author="eyeo GmbH"
type="circumvention"/>
<subscription title="EasyPrivacy"
specialization="privacy protection"
url="https://easylist-downloads.adblockplus.org/easyprivacy.txt"
homepage="https://easylist.to/"
author="fanboy, MonztA, Famlam, Khrin"
type="privacy"/>
<subscription title="Fanboy&#39;s Social Blocking List"
specialization="removes social media integration"
url="https://easylist-downloads.adblockplus.org/fanboy-social.txt"
homepage="https://easylist.to/"
author="fanboy, Famlam, MonztA"
type="social"/>
</subscriptions>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment