MCPcopy Create free account
hub / github.com/zxlie/FeHelper / turnLight

Function turnLight

apps/static/js/dark-mode.js:283–315  ·  view source on GitHub ↗
(auto)

Source from the content-addressed store, hash-verified

281 }
282
283 function turnLight(auto) {
284 if (isFirefox) return;
285
286 document.documentElement.setAttribute('dark-mode', auto ? 'on' : 'off');
287
288 if (!auto) {
289 let bg = document.getElementById('_fh_filter_bkgnd');
290 if (bg) {
291 bg.style.display = 'none';
292 }
293 if (filterObserver) {
294 filterObserver.disconnect();
295 filterObserver = null;
296 }
297 return;
298 }
299
300 let hasChromeRuntime = typeof chrome !== 'undefined' && chrome.runtime;
301 if (hasChromeRuntime && !chrome.runtime.lastError) {
302 if (window === window.top) {
303 window.scrollBy(0, 1);
304 window.scrollBy(0, -1);
305 }
306 window.setTimeout(addOrUpdateExtraElements, 2000);
307 addOrUpdateExtraElements();
308 if (!filterObserver) {
309 filterObserver = new MutationObserver(function (mutations) {
310 addOrUpdateExtraElements();
311 });
312 filterObserver.observe(document.body, {attributes: true, childList: true, characterData: true});
313 }
314 }
315 }
316
317 // 自动开关等
318 function turnLightAuto() {

Callers 1

syncAutoDarkModeFunction · 0.70

Calls 1

addOrUpdateExtraElementsFunction · 0.85

Tested by

no test coverage detected