MCPcopy Create free account
hub / github.com/Yantesoft/LinuxdoAssistant / toggleSwitch

Function toggleSwitch

linuxdo-helper.user.js:251–275  ·  view source on GitHub ↗

* 切换助手开关状态

()

Source from the content-addressed store, hash-verified

249 * 切换助手开关状态
250 */
251 function toggleSwitch() {
252 const currentState = getSwitchState();
253 const newState = !currentState;
254
255 setTabValue(STORAGE_KEYS.enabled, newState);
256
257 if (newState) {
258 const delay = randomDelay(
259 RANDOM_DELAY_CONFIG.enableJumpDelayMin,
260 RANDOM_DELAY_CONFIG.enableJumpDelayMax
261 );
262
263 console.log(`Linuxdo助手已启用,${delay}ms 后跳转到最新页面`);
264 setTabValue(STORAGE_KEYS.currentTopicNeedsMinimumReadTime, false);
265
266 setTimeout(() => {
267 if (getSwitchState()) {
268 window.location.href = URLS.newPosts;
269 }
270 }, delay);
271 } else {
272 stopScrolling();
273 console.log('Linuxdo助手已禁用');
274 }
275 }
276
277 /**
278 * 获取话题优先模式状态

Callers 1

createSwitchButtonFunction · 0.85

Calls 4

getSwitchStateFunction · 0.85
setTabValueFunction · 0.85
randomDelayFunction · 0.85
stopScrollingFunction · 0.85

Tested by

no test coverage detected