Skip to content

Instantly share code, notes, and snippets.

@moonhouse
Created September 7, 2023 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moonhouse/f1e85be89099a9a3f7a82a6c301ed9e3 to your computer and use it in GitHub Desktop.
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
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