-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.js
22 lines (18 loc) · 851 Bytes
/
save.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let playedDivs = [...document.getElementsByTagName("div")]
.filter(div => div.hasAttribute("played") && div.title)
.map(div => div.textContent)
// .map(element => console.warn('2', element))
let clipBoardValue = `// ${window.location}\n\n`
clipBoardValue += `let artistsToLoad = ${JSON.stringify(playedDivs)};\n\n`
clipBoardValue += `[...document.getElementsByTagName("div")].forEach(div => {
div.onclick = () => div.hasAttribute('played') ? div.removeAttribute('played') : div.setAttribute('played', true)
artistsToLoad.includes(div.textContent) && div.setAttribute("played", true)
})`
let el = document.createElement('textarea')
el.value = clipBoardValue
el.setAttribute('readonly', '')
el.style = { position: 'absolute', left: '-9999px' }
document.body.appendChild(el)
el.select()
document.execCommand('copy')
document.body.removeChild(el)