Skip to content

Commit

Permalink
伪元素支持网络图片
Browse files Browse the repository at this point in the history
  • Loading branch information
caol64 committed Dec 11, 2024
1 parent 5d0601e commit a1dfc3f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions WenYan/Resources.bundle/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,19 @@ function buildPseudoSpan(beforeRresults) {
for (const [k, v] of beforeRresults) {
if (v.includes("url(")) {
const svgMatch = v.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/);
const base64SvgMatch = v.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/);
const httpMatch = v.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
if (svgMatch) {
const svgCode = decodeURIComponent(svgMatch[1]);
span.innerHTML = svgCode;
} else {
const base64SvgMatch = v.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/);
if (base64SvgMatch) {
const decodedString = atob(base64SvgMatch[1]);
span.innerHTML = decodedString;
}
} else if (base64SvgMatch) {
const decodedString = atob(base64SvgMatch[1]);
span.innerHTML = decodedString;
} else if (httpMatch) {
const img = document.createElement('img');
img.src = httpMatch[1];
img.setAttribute("style", "vertical-align: top;");
span.appendChild(img);
}
beforeRresults.delete(k);
}
Expand Down

0 comments on commit a1dfc3f

Please sign in to comment.