()
| 241 | |
| 242 | // 初始化 |
| 243 | function initialize() { |
| 244 | let defaultWords = { |
| 245 | 'key_123': { |
| 246 | limit: ['baidu'], |
| 247 | 'info': '汉字测试', |
| 248 | 'words': ['抖音', '快手', '网页', '平台', '的', '最', '一', '个', '多', '服务', '大'], |
| 249 | 'color': '#85d228', |
| 250 | 'textcolor': '#3467eb' |
| 251 | |
| 252 | }, |
| 253 | 'key_124': { |
| 254 | limit: [], |
| 255 | 'info': '数字测试', |
| 256 | 'words': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], |
| 257 | 'color': '#48c790', |
| 258 | 'textcolor': '#3467eb' |
| 259 | |
| 260 | }, |
| 261 | 'key_3379656389': { |
| 262 | limit: [], |
| 263 | 'info': '字母测试', |
| 264 | 'words': ['a', 'b', 'c', 'd', 'e', 'f', 't', 'y', 'u', 'i', 'o', 'k', 'j', 'h', 'g', 's', 'z', 'x', 'v', 'n', 'm'], |
| 265 | 'color': '#e33544', |
| 266 | 'textcolor': '#3467eb' |
| 267 | }, |
| 268 | 'key_4947181948': { |
| 269 | limit: [], |
| 270 | 'info': '相同的字可以显示各个分组的标题', |
| 271 | 'words': ['的', '最', '一', '个', '多', '服务', '大'], |
| 272 | 'color': '#6e7bdd', |
| 273 | 'textcolor': '#e33544' |
| 274 | } |
| 275 | } |
| 276 | // 设置关键字默认值 |
| 277 | if (!GM_getValue('key')) { GM_setValue('key', defaultWords) } |
| 278 | if (Object.keys(GM_getValue('key')).length == 0) { GM_setValue('key', defaultWords) } |
| 279 | // GM_setValue("key",this.defaultWords); |
| 280 | |
| 281 | let cache = GM_getValue('key') |
| 282 | Object.keys(cache).forEach(key => { |
| 283 | let defult = { |
| 284 | limit: [], |
| 285 | info: '', |
| 286 | words: [], |
| 287 | color: '#85d228' |
| 288 | } |
| 289 | Object.keys(defult).forEach((key2) => { |
| 290 | if (!cache[key][key2]) { |
| 291 | console.log(defult[key2]) |
| 292 | cache[key][key2] = defult[key2] |
| 293 | } |
| 294 | }) |
| 295 | }) |
| 296 | |
| 297 | GM_setValue('key', cache) |
| 298 | } |
| 299 | /** |
| 300 | * @description: 遍历找出所有文本节点 |
no outgoing calls
no test coverage detected