MCPcopy Index your code
hub / github.com/hoothin/UserScripts / hasBg

Function hasBg

Picviewer CE+/dist.user.js:26556–26588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26554 let bgReg = /.*url\(\s*["']?([^ad\s'"#].+?)["']?\s*\)([^'"]|$)/i;
26555 let bgRegLong = /^\s*url\(\s*["']?([^ad\s'"#].+?)["']?\s*\)([^'"]|$)/i;
26556 let result, targetBg, hasBg = node => {
26557 if(/^(html|body|#document)$/i.test(node.nodeName) || node.nodeType != 1){
26558 return false;
26559 }
26560 if (node.clientWidth <= prefs.floatBar.minSizeLimit.w || node.clientHeight <= prefs.floatBar.minSizeLimit.h) {
26561 return false;
26562 }
26563 targetBg = "";
26564 let nodeStyle = unsafeWindow.getComputedStyle(node);
26565
26566 let bg = nodeStyle.backgroundRepeatX != "repeat" && nodeStyle.backgroundRepeatY != "repeat" && nodeStyle.backgroundImage;
26567 if (bg && bg !== "none") {
26568 targetBg = nodeStyle.backgroundImage.match(bg.length > 500 ? bgRegLong : bgReg);
26569 }
26570 if (!targetBg) {
26571 nodeStyle = unsafeWindow.getComputedStyle(node, "::before");
26572 bg = nodeStyle.backgroundRepeatX != "repeat" && nodeStyle.backgroundRepeatY != "repeat" && nodeStyle.backgroundImage;
26573 if (bg && bg !== "none") {
26574 targetBg = nodeStyle.backgroundImage.match(bg.length > 500 ? bgRegLong : bgReg);
26575 }
26576 }
26577 if (!targetBg) {
26578 nodeStyle = unsafeWindow.getComputedStyle(node, "::after");
26579 bg = nodeStyle.backgroundRepeatX != "repeat" && nodeStyle.backgroundRepeatY != "repeat" && nodeStyle.backgroundImage;
26580 if (bg && bg !== "none") {
26581 targetBg = nodeStyle.backgroundImage.match(bg.length > 500 ? bgRegLong : bgReg);
26582 }
26583 }
26584 if (targetBg) {
26585 targetBg = targetBg[1].replace(/\\"/g, '"');
26586 }
26587 return targetBg;
26588 };
26589 if (target.nodeName.toUpperCase() != 'IMG') {
26590 let nsrc, imgPN, imgPA, imgPE = [];
26591 try {

Callers 1

checkFloatBarFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected