Skip to content

Commit

Permalink
Fix Disqus blinking Privacy Policy (#3493)
Browse files Browse the repository at this point in the history
* Fix Disqus blinking Privacy Policy

* Improve selector and add clean url params

* Update validUntil

* Lint

---------

Co-authored-by: Clément Biron <[email protected]>
  • Loading branch information
afisher3578 and clementbiron authored Oct 23, 2024
1 parent d6ab5ed commit b8b6ace
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
32 changes: 32 additions & 0 deletions declarations/Disqus.filters.js
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions declarations/Disqus.history.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
14 changes: 12 additions & 2 deletions declarations/Disqus.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
}

0 comments on commit b8b6ace

Please sign in to comment.