Created
September 7, 2023 09:08
-
-
Save Ambrosiani/ec2116cca0a58523e8822f133757fc57 to your computer and use it in GitHub Desktop.
Bookmarklet med antal träffar från Svenska dagstidningar
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
// bookmarklet som hämtar årtal och antal träfflistar från aktuell sökning på tidningar.kb.se och lägger i urklipp. Lägg som bokmärke i webbläsaren! | |
javascript:(function() { | |
var csv = 'year,count\n'; | |
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 + '\n'; | |
}); | |
navigator.clipboard.writeText(csv); | |
alert(csv); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
directly to downloaded file instead of clipboard: https://gist.github.com/moonhouse/f1e85be89099a9a3f7a82a6c301ed9e3