MCPcopy Create free account
hub / github.com/Yorick-Ryu/deep-share / initGeminiMathCopy

Function initGeminiMathCopy

scripts/copyGeminiMath.js:132–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130
131// Initialize when DOM is loaded
132function initGeminiMathCopy() {
133
134 console.debug('DeepShare Gemini Math copy functionality initialized');
135
136 // 绑定在 window 的捕获阶段(最高层级限制),保证先于 document 执行
137 window.addEventListener('click', handleGeminiMathClick, true);
138
139 // 首先加载设置
140 loadSettings();
141
142 // Use MutationObserver to handle dynamically added math elements
143 const observer = new MutationObserver((mutations) => {
144 mutations.forEach(mutation => {
145 if (mutation.addedNodes.length > 0) {
146 enableGeminiMathCopy();
147 }
148 });
149 });
150
151 // Start observing
152 observer.observe(document.body, {
153 childList: true,
154 subtree: true
155 });
156
157 // Listen for settings changes and re-apply
158 chrome.storage.onChanged.addListener((changes) => {
159 if (changes.enableFormulaCopy) {
160 formulaSettings.enableFormulaCopy = changes.enableFormulaCopy.newValue;
161 }
162 if (changes.formulaFormat) {
163 formulaSettings.formulaFormat = changes.formulaFormat.newValue;
164 }
165 if (changes.formulaEngine) {
166 formulaSettings.formulaEngine = changes.formulaEngine.newValue;
167 }
168 // 如果相关设置有变更,更新所有元素
169 if (changes.enableFormulaCopy || changes.formulaFormat || changes.formulaEngine) {
170 updateAllElements();
171 }
172 });
173}
174
175// Run initialization
176if (document.readyState === 'loading') {

Callers 1

copyGeminiMath.jsFile · 0.85

Calls 4

enableGeminiMathCopyFunction · 0.85
debugMethod · 0.80
loadSettingsFunction · 0.70
updateAllElementsFunction · 0.70

Tested by

no test coverage detected