Fix image relative url error
修复相对链接图片无法显示问题
This commit is contained in:
+30
-17
@@ -121,26 +121,31 @@ const getHTML = () => {
|
||||
if (location.host === "mp.weixin.qq.com") {
|
||||
console.log("微信");
|
||||
|
||||
return formatHTML(document.querySelector(".rich_media_content").innerHTML);
|
||||
return formatHTML(document.querySelector(".rich_media_content").innerHTML, {
|
||||
baseURL: location.origin,
|
||||
});
|
||||
}
|
||||
|
||||
// 腾讯云开发者社区
|
||||
if (location.host === "cloud.tencent.com") {
|
||||
console.log("腾讯云");
|
||||
|
||||
return formatHTML(document.querySelector(".rno-markdown").innerHTML, (doc) => {
|
||||
// 替换掉腾讯云自己的链接
|
||||
const qcloudLinkEl = doc.querySelectorAll("a");
|
||||
qcloudLinkEl.forEach((el) => {
|
||||
if (el.href.includes("qcloud")) {
|
||||
el.parentNode.replaceChild(document.createTextNode(el.innerText), el);
|
||||
}
|
||||
});
|
||||
return formatHTML(document.querySelector(".rno-markdown").innerHTML, {
|
||||
formatter: (doc) => {
|
||||
// 替换掉腾讯云自己的链接
|
||||
const qcloudLinkEl = doc.querySelectorAll("a");
|
||||
qcloudLinkEl.forEach((el) => {
|
||||
if (el.href.includes("qcloud")) {
|
||||
el.parentNode.replaceChild(document.createTextNode(el.innerText), el);
|
||||
}
|
||||
});
|
||||
|
||||
const mdTextEl = doc.querySelectorAll(".rno-markdown__textlink-new") as NodeListOf<HTMLElement>;
|
||||
mdTextEl.forEach((el) => {
|
||||
el.parentNode.replaceChild(document.createTextNode(el.innerText), el);
|
||||
});
|
||||
const mdTextEl = doc.querySelectorAll(".rno-markdown__textlink-new") as NodeListOf<HTMLElement>;
|
||||
mdTextEl.forEach((el) => {
|
||||
el.parentNode.replaceChild(document.createTextNode(el.innerText), el);
|
||||
});
|
||||
},
|
||||
baseURL: location.origin,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -150,7 +155,9 @@ const getHTML = () => {
|
||||
if (itemPropArticle) {
|
||||
console.log("掘金");
|
||||
|
||||
return formatHTML(itemPropArticle.innerHTML);
|
||||
return formatHTML(itemPropArticle.innerHTML, {
|
||||
baseURL: location.origin,
|
||||
});
|
||||
}
|
||||
|
||||
// CSDN
|
||||
@@ -159,7 +166,9 @@ const getHTML = () => {
|
||||
if (contentViews) {
|
||||
console.log("CSDN");
|
||||
|
||||
return formatHTML(contentViews.innerHTML);
|
||||
return formatHTML(contentViews.innerHTML, {
|
||||
baseURL: location.origin,
|
||||
});
|
||||
}
|
||||
|
||||
// 通用模式
|
||||
@@ -168,7 +177,9 @@ const getHTML = () => {
|
||||
if (articleEl) {
|
||||
console.log("文章标签");
|
||||
|
||||
return formatHTML(articleEl.innerHTML);
|
||||
return formatHTML(articleEl.innerHTML, {
|
||||
baseURL: location.origin,
|
||||
});
|
||||
}
|
||||
|
||||
// 尝试匹配到文章
|
||||
@@ -196,7 +207,9 @@ const getHTML = () => {
|
||||
}
|
||||
}
|
||||
|
||||
return formatHTML(parentEl.innerHTML);
|
||||
return formatHTML(parentEl.innerHTML, {
|
||||
baseURL: location.origin,
|
||||
});
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user