Skip to content

Instantly share code, notes, and snippets.

View O-Zone's full-sized avatar

Hasse Feldthaus O-Zone

  • FOA
  • Copenhagen
View GitHub Profile
@O-Zone
O-Zone / harvestNapsterFavorites.js
Created March 12, 2024 19:07
Script to harvest all song/title/album from your favorite list in Napster and export them to a .csv file
var mainListe = document.getElementsByClassName('ant-table-tbody')[0].children;
var harvestedTunes = [];
for(i = 0; i < mainListe.length ; i++){
let currentSong = mainListe[i];
let albumAndArtist = currentSong.children[0].innerText.split('\n');
let tune = currentSong.children[1].innerText.split('\n');
let duration = currentSong.children[2].innerText.split('\n');
harvestedTunes.push([albumAndArtist[0], albumAndArtist[2], tune[0], duration[0]]);
}
@O-Zone
O-Zone / HarvestYoutubeCollection.js
Created August 2, 2020 15:03
Script to harvest all song/title/album from the music.youtube.com/library/songs/ and export them to a .csv file
var waitForContentSeconds = 10;
var bottomTrials = 0;
var pageHeight = 0;
function grabYoutubeList() {
var AllNodes = [...document.getElementsByTagName('ytmusic-shelf-renderer')[0].getElementsByTagName('ytmusic-responsive-list-item-renderer')];
AllNodes.shift(); // remove first "blend" element
var harvestedTunes = AllNodes.map(t => {
var items = [...t.children[3].getElementsByTagName('yt-formatted-string')].map(n => n.getAttribute('title').replace(/"/g,'”'));
return `"${items[0]}", "${items[1]}", "${items[2]}"<br>\n`;
});
@O-Zone
O-Zone / minDigits
Created June 18, 2016 06:58
Polyfill that makes you print out a Number in at least a certain number of digits. Examples: 7.minDigits(3) => '007'; 64.3.minDigits(4) => '0064.3'; 432.minDigits(2) => '432'
Number.prototype.minDigits = function (d) {
if ('number' !== typeof d) {
return this.toString();
}
var s = this.toString().split('.');
while (s[0].length < d) {
s[0] = '0' + s[0];
}
return s[0] + (s[1] ? '.' + s[1] : '');
}
@O-Zone
O-Zone / transitionEnd.js
Last active November 23, 2023 22:43
Get the name of the browsers transitionEnd event. After calling this, window.transitionEnd will contain the browser specific name of the transitionEnd event. This is an extract of EvandroLG's transitionEnd snippet, without all support for testing different elements and using cache.
(function (window) {
var transitions = {
'transition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'otransitionend'
},
elem = document.createElement('div');
for(var t in transitions){