Created
September 7, 2023 10:02
-
-
Save moonhouse/f1e85be89099a9a3f7a82a6c301ed9e3 to your computer and use it in GitHub Desktop.
Bookmarklet med antal träffar från Svenska dagstidningar att laddas ned som CSV. Bygger på https://gist.github.com/Ambrosiani/ec2116cca0a58523e8822f133757fc57 och https://stackoverflow.com/questions/17900671/bookmarklet-to-save-file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { | |
var csv = 'data:year,count%250A'; | |
var bars = document.querySelectorAll('.bar.year'); | |
bars.forEach(function(bar) { | |
var dataDate = bar.getAttribute('data-date'); | |
var year = new Date(dataDate).getFullYear(); | |
var count = bar.getAttribute('data-count'); | |
csv += year + ',' + count + '%250A'; | |
}); | |
var a = document.createElement('a'); | |
a.href = csv; | |
a.download = document.getElementById("search").value+'.csv'; | |
document.body.appendChild(a); | |
a.click(); | |
a.parentNode.removeChild(a); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment