MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / initTaskConfig

Function initTaskConfig

tech-study.js:133–158  ·  view source on GitHub ↗

* @description 初始化配置

()

Source from the content-addressed store, hash-verified

131 * @description 初始化配置
132 */
133function initTaskConfig() {
134 try {
135 const taskTemp = JSON.parse(GM_getValue('taskConfig'));
136 if (taskTemp && Array.isArray(taskTemp)) {
137 if (taskTemp.length === taskConfig.length) {
138 taskConfig.forEach((task, i) => {
139 task.active = taskTemp[i].active;
140 });
141 }
142 }
143 // 监听值变化
144 GM_addValueChangeListener('taskConfig', (key, oldVal, newVal, remote) => {
145 if (remote) {
146 const taskTemp = JSON.parse(newVal);
147 if (taskTemp && Array.isArray(taskTemp)) {
148 if (taskTemp.length === taskConfig.length) {
149 taskConfig.forEach((task, i) => {
150 task.active = taskTemp[i].active;
151 });
152 }
153 }
154 }
155 });
156 }
157 catch (e) { }
158}
159/**
160 * @description 初始化配置
161 */

Callers 1

tech-study.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected