这个版本有关闭功能了
Browse files- youtube_sub.js +31 -26
youtube_sub.js
CHANGED
|
@@ -783,6 +783,11 @@ GM_addStyle(`
|
|
| 783 |
|
| 784 |
// Add popup to document
|
| 785 |
document.body.appendChild(popup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
}
|
| 787 |
|
| 788 |
// Ensure markdown container exists
|
|
@@ -833,32 +838,32 @@ GM_addStyle(`
|
|
| 833 |
|
| 834 |
console.log('API Response:', response);
|
| 835 |
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
|
| 863 |
} catch (error) {
|
| 864 |
console.error('API call failed:', error);
|
|
|
|
| 783 |
|
| 784 |
// Add popup to document
|
| 785 |
document.body.appendChild(popup);
|
| 786 |
+
|
| 787 |
+
// Add click outside listener
|
| 788 |
+
document.addEventListener('click', () => {
|
| 789 |
+
popup.classList.remove('show');
|
| 790 |
+
});
|
| 791 |
}
|
| 792 |
|
| 793 |
// Ensure markdown container exists
|
|
|
|
| 838 |
|
| 839 |
console.log('API Response:', response);
|
| 840 |
|
| 841 |
+
const content = response?.data?.response;
|
| 842 |
+
if (!content) {
|
| 843 |
+
throw new Error('No content in API response');
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
// Create text node instead of using innerHTML
|
| 847 |
+
const markdownContent = marked.parse(content);
|
| 848 |
+
if (markdownContent) {
|
| 849 |
+
// Clear existing content
|
| 850 |
+
while (markdownContainer.firstChild) {
|
| 851 |
+
markdownContainer.removeChild(markdownContainer.firstChild);
|
| 852 |
+
}
|
| 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);
|
| 861 |
+
markdownContainer.appendChild(fragment);
|
| 862 |
+
|
| 863 |
+
popup.classList.add('show');
|
| 864 |
+
} else {
|
| 865 |
+
throw new Error('Failed to parse markdown content');
|
| 866 |
+
}
|
| 867 |
|
| 868 |
} catch (error) {
|
| 869 |
console.error('API call failed:', error);
|