sonygod commited on
Commit
5cb75ab
·
1 Parent(s): 0b147a7

这个版本有关闭功能了

Browse files
Files changed (1) hide show
  1. 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
- const content = response?.data?.response;
837
- if (!content) {
838
- throw new Error('No content in API response');
839
- }
840
-
841
- // Create text node instead of using innerHTML
842
- const markdownContent = marked.parse(content);
843
- if (markdownContent) {
844
- // Clear existing content
845
- while (markdownContainer.firstChild) {
846
- markdownContainer.removeChild(markdownContainer.firstChild);
847
- }
848
-
849
- // Create temporary container
850
- const temp = document.createElement('div');
851
- temp.textContent = markdownContent;
852
-
853
- // Safely append text content
854
- const fragment = document.createDocumentFragment();
855
- fragment.appendChild(temp);
856
- markdownContainer.appendChild(fragment);
857
-
858
- popup.classList.add('show');
859
- } else {
860
- throw new Error('Failed to parse markdown content');
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);