Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
707 B
1
Indexable
Never
var headers = {};
for (var header of document.querySelectorAll("head meta, head link, head script")) {
  var name = header.tagName.toLowerCase();
  if (name === "meta") {
    var key = header.getAttribute("name") || header.getAttribute("property");
  } else if (name === "link" || name === "script") {
    var key = header.getAttribute("rel");
  }
  
  var value = null;
  if (header.hasAttribute("content")) {
    value = header.getAttribute("content");
  } else if (header.hasAttribute("href")) {
    value = header.getAttribute("href");
  } else if (header.hasAttribute("src")) {
    value = header.getAttribute("src");
  }
  
  if (key && value) {
    headers[key] = value;
  }
}

console.log(headers);