Skip to content

Instantly share code, notes, and snippets.

@Eseperio
Last active July 16, 2019 09:34
Show Gist options
  • Save Eseperio/0dbb6597f8c63364c47463c3ff359668 to your computer and use it in GitHub Desktop.
Save Eseperio/0dbb6597f8c63364c47463c3ff359668 to your computer and use it in GitHub Desktop.
A snippet to extract all file extension names from wikipedia pages.
/**
* This snippet is used to extract all file extension names from wikipedia pages.
*
* Usage: Copy this snippet and paste on Chrome console. Do it for each extensions page available.
* After that, get the json using `localStorage.getItem('extensions')`
* @see https://en.wikipedia.org/wiki/List_of_filename_extensions
* @type {string}
*/
var memorySlot='extensions';
var memory = localStorage.getItem(memorySlot);
if (!memory) {
var data = {};
} else {
var data = JSON.parse(memory);
}
$('.wikitable tr').each(function (k, v) {
let tds = $(v).find('td');
let extension = $(tds[0]).text().toString().replace("\n",'');
let description = ($(tds[1]).text()).toString().replace("\n",'');
if (typeof data[extension] == "undefined") {
data[extension] = {
'descriptions': []
};
}
data[extension].descriptions.push(description)
});
localStorage.setItem(memorySlot, JSON.stringify(data));
console.log(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment