支持markdown格式了
Browse files- youtube_sub.js +14 -0
youtube_sub.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
| 10 |
// @grant GM_xmlhttpRequest
|
| 11 |
// @connect sonygod-flash.hf.space
|
| 12 |
// @require https://cdn.jsdelivr.net/npm/marked/marked.min.js
|
|
|
|
| 13 |
// @run-at document-end
|
| 14 |
// ==/UserScript==
|
| 15 |
|
|
@@ -853,8 +854,21 @@ GM_addStyle(`
|
|
| 853 |
|
| 854 |
// Create temporary container
|
| 855 |
const temp = document.createElement('div');
|
|
|
|
| 856 |
temp.textContent = markdownContent;
|
| 857 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 858 |
// Safely append text content
|
| 859 |
const fragment = document.createDocumentFragment();
|
| 860 |
fragment.appendChild(temp);
|
|
|
|
| 10 |
// @grant GM_xmlhttpRequest
|
| 11 |
// @connect sonygod-flash.hf.space
|
| 12 |
// @require https://cdn.jsdelivr.net/npm/marked/marked.min.js
|
| 13 |
+
// @require https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.6/purify.min.js
|
| 14 |
// @run-at document-end
|
| 15 |
// ==/UserScript==
|
| 16 |
|
|
|
|
| 854 |
|
| 855 |
// Create temporary container
|
| 856 |
const temp = document.createElement('div');
|
| 857 |
+
|
| 858 |
temp.textContent = markdownContent;
|
| 859 |
|
| 860 |
+
|
| 861 |
+
// Sanitize the HTML content using DOMPurify
|
| 862 |
+
const sanitizedHtml = DOMPurify.sanitize(markdownContent, {
|
| 863 |
+
RETURN_TRUSTED_TYPE: true
|
| 864 |
+
});
|
| 865 |
+
|
| 866 |
+
try{
|
| 867 |
+
temp.innerHTML = sanitizedHtml;
|
| 868 |
+
}catch(e){
|
| 869 |
+
console.error('DOMPurify error:', e);
|
| 870 |
+
}
|
| 871 |
+
|
| 872 |
// Safely append text content
|
| 873 |
const fragment = document.createDocumentFragment();
|
| 874 |
fragment.appendChild(temp);
|