Last active
August 20, 2023 16:41
-
-
Save Sarverott/2253c39dee4ff650a6b6f51b82d1490d to your computer and use it in GitHub Desktop.
extract MIME type table from [ https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types ] works in live dev console
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
var result=[]; | |
document.querySelectorAll(".table-container table tr").forEach(function(x){ | |
var currentRow=[]; | |
x.childNodes.forEach(function(y){ | |
if(y.nodeType==1){ | |
currentRow.push(y.innerText) | |
} | |
}) | |
result.push(currentRow); | |
}); | |
console.log(JSON.stringify(result, null, "\t")) |
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
var result={}; | |
document.querySelectorAll(".table-container table tr").forEach(function(x){ | |
var currentKey=null; | |
var currentValue=null; | |
x.childNodes.forEach(function(y){ | |
if(y.nodeType==1){ | |
if(currentKey===null){ | |
currentKey=y.innerText; | |
}else{ | |
currentValue=y.innerText; | |
} | |
} | |
}) | |
if(currentValue.indexOf(" ")>0){ | |
currentValue=currentValue.substring(0, currentValue.indexOf(' ')) | |
} | |
if(currentValue.indexOf(";")>0){ | |
currentValue=currentValue.substring(0, currentValue.indexOf(';')) | |
} | |
currentKey.split(", ").forEach(function(z){ | |
result[z]=currentValue; | |
}) | |
}) | |
console.log(JSON.stringify(result, null, "\t")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result of test: