diff --git a/declarations/Disqus.filters.js b/declarations/Disqus.filters.js new file mode 100644 index 00000000..581f56b1 --- /dev/null +++ b/declarations/Disqus.filters.js @@ -0,0 +1,32 @@ +export function cleanHref(document) { + Array.from(document.querySelectorAll('a')).forEach(link => { + link.href = cleanURLParams(link.href); + }); +} + +export function cleanSrc(document) { + Array.from(document.querySelectorAll('img')).forEach(img => { + img.src = cleanURLParams(img.src); + }); +} + +function cleanURLParams(url) { + const searchString = 'https://downloads.intercomcdn.com'; + + if (url.includes(searchString)) { + try { + const parsedUrl = new URL(url); + + parsedUrl.searchParams.delete('expires'); + parsedUrl.searchParams.delete('req'); + parsedUrl.searchParams.delete('signature'); + const cleanedUrl = parsedUrl.toString(); + + return cleanedUrl; + } catch (error) { + return url; + } + } + + return url; +} diff --git a/declarations/Disqus.history.json b/declarations/Disqus.history.json index a30653b7..3a8ce184 100644 --- a/declarations/Disqus.history.json +++ b/declarations/Disqus.history.json @@ -4,6 +4,12 @@ "fetch": "https://help.disqus.com/en/articles/1717103-disqus-privacy-policy", "select": "body", "validUntil": "2020-12-08T16:00:00.000Z" + }, + { + "fetch": "https://help.disqus.com/en/articles/1717103-disqus-privacy-policy", + "select": ".article", + "remove": ".article__meta", + "validUntil": "2023-10-23T12:35:14.000Z" } ], "Terms of Service": [ diff --git a/declarations/Disqus.json b/declarations/Disqus.json index 92933f97..4d869df0 100644 --- a/declarations/Disqus.json +++ b/declarations/Disqus.json @@ -5,12 +5,22 @@ "Privacy Policy": { "fetch": "https://help.disqus.com/en/articles/1717103-disqus-privacy-policy", "select": ".article", - "remove": ".article__meta" + "remove": [ + ".article__meta", + ".avatar__photo" + ], + "filter": [ + "cleanHref", + "cleanSrc" + ] }, "Terms of Service": { "fetch": "https://help.disqus.com/en/articles/1717102-terms-of-service", "select": ".article", - "remove": ".article__meta" + "remove": [ + ".article__meta", + ".avatar__photo" + ] } } }