Created
May 29, 2015 12:51
-
-
Save mvasilkov/96e6361f49a95b3a0f4e to your computer and use it in GitHub Desktop.
Google Chrome extension (early access) https://chrome.google.com/webstore/detail/plaintextify/emmfeegdeiphciknpfmglmpekijpkann
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 res = [] | |
parse(document.documentElement) | |
chrome.runtime.sendMessage(res) | |
function parse(node) { | |
var i, a, name = node.tagName.toLowerCase() | |
res.push({type: 'o', name: name}) | |
for (i = 0; i < node.attributes.length; ++i) { | |
a = node.attributes[i] | |
res.push({type: 'a', name: a.name, value: a.value}) | |
} | |
for (i = 0; i < node.childNodes.length; ++i) { | |
a = node.childNodes[i] | |
if (a.nodeType === Node.ELEMENT_NODE) | |
parse(a) | |
else if (a.nodeType === Node.TEXT_NODE) | |
res.push({type: 't', text: a.textContent}) | |
} | |
res.push({type: 'c', name: name}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment