MCPcopy
hub / github.com/hoothin/UserScripts / anylizeEle

Function anylizeEle

Picviewer CE+/Picviewer CE+.user.js:18637–18802  ·  view source on GitHub ↗
(total, node)

Source from the content-addressed store, hash-verified

18635 let body = getBody(document);
18636 let linkMedias = [];
18637 function anylizeEle(total, node) {
18638 if (/^iframe$/i.test(node.nodeName)) {
18639 if (node.name == "pagetual-iframe") return total;
18640 if (!node.src || (node.src && (node.src == "about:blank" || node.src.replace(/\/[^\/]*$/,"").indexOf(location.hostname) != -1))) {
18641 try {
18642 arrayFn.forEach.call(node.contentWindow.document.querySelectorAll('*'), function(n){
18643 total = anylizeEle(total, n);
18644 });
18645 } catch(e) {
18646 debug(e.toString());
18647 }
18648 }
18649 return total;
18650 } else if (/^img$/i.test(node.nodeName)) {
18651 total.push(node);
18652 } else if (/^svg$/i.test(node.nodeName)) {
18653 if (node.clientHeight != 0 && (!node.classList || !node.classList.contains("pagetual"))) {
18654 try {
18655 let images = node.querySelectorAll('image');
18656 if (images.length) {
18657 arrayFn.forEach.call(images, function(image){
18658 let src = image.href && image.href.baseVal;
18659 if (src) {
18660 image.src = canonicalUri(src, image.ownerDocument.URL, image.ownerDocument.baseURI);
18661 total.push(image);
18662 }
18663 });
18664 } else {
18665 const xml = new XMLSerializer().serializeToString(node);
18666 const ImgBase64 = `data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(xml)))}`;
18667 node.src = ImgBase64;
18668 total.push(node);
18669 }
18670 } catch(e) {
18671 debug(e);
18672 }
18673 }
18674 } else if (/^canvas$/i.test(node.nodeName)) {
18675 if (node.clientHeight != 0) {
18676 try {
18677 if (!node.src) {
18678 node.src = node.toDataURL("image/png");
18679 }
18680 } catch(e) {}
18681 }
18682 if (!node.src && node.dataset.src) {
18683 node.src = node.dataset.src;
18684 }
18685 if (node.src) {
18686 total.push(node);
18687 }
18688 } else if (/^a$/i.test(node.nodeName)) {
18689 if (node.href && node.href.length < 300 && imageReg.test(node.href)) {
18690 let src = node.href;
18691 if (/[&\?]url\=/.test(src)) {
18692 src = src.replace(/.*[&\?]url\=(.*?)(&.*|$)/, "$1");
18693 try {
18694 src = decodeURIComponent(src);

Callers 1

initFunction · 0.70

Calls 4

debugFunction · 0.85
containsMethod · 0.80
canonicalUriFunction · 0.70
icon2Base64Function · 0.70

Tested by

no test coverage detected