Skip to content

Commit

Permalink
Closes #83 : Add H&M - Commercial Terms
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu1400 authored and clementbiron committed May 19, 2022
1 parent 1f0d800 commit fa50ba7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions declarations/H&M.filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @param { Document } document
*/
export function addTitles(document) {
document.querySelectorAll('b').forEach(el => {
if (el.textContent.includes('.')) {
// h2 is already used
const h3 = document.createElement("h3")
h3.textContent = el.textContent
el.replaceWith(h3)
}
})
}

/**
* @param { Document } document
*/
export function fixBrTag(document) {
document.querySelectorAll('i, b').forEach(el => {
if (el.innerHTML.includes('<br>')) {
el.innerHTML = el.innerHTML.replace('<br>', '')
// and then
el.after(document.createElement("br"))
}
})
}
11 changes: 11 additions & 0 deletions declarations/H&M.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "H&M",
"documents": {
"Commercial Terms": {
"fetch": "https://www2.hm.com/fr_fr/service-clients/legal-and-privacy/terms-and-conditions.html",
"select": ["div.main"],
"executeClientScripts": true,
"filter": ["addTitles", "fixBrTag"]
}
}
}

0 comments on commit fa50ba7

Please sign in to comment.