| 332 | |
| 333 | // 高亮 |
| 334 | class HIGHTLIGHT { |
| 335 | |
| 336 | // 需要高亮的关键字 |
| 337 | /**通过规则新建关键字列表,解决一个关键字会存在多个分类中 |
| 338 | * 将{ |
| 339 | * key1{ |
| 340 | * words:[word1,word2] |
| 341 | * }, |
| 342 | * key2{ |
| 343 | * words:[word3,word4] |
| 344 | * } |
| 345 | * } |
| 346 | * 转换为map{ |
| 347 | * word1:key1 |
| 348 | * word2:key1 |
| 349 | * word4:key2 |
| 350 | * word3:key2 |
| 351 | * } |
| 352 | * @description: |
| 353 | * @return {map}map{ |
| 354 | * |
| 355 | * classesKey=>分类标签,类型string |
| 356 | * |
| 357 | * infoList=>提示词,数组["汉字","字符"] |
| 358 | * |
| 359 | * } |
| 360 | */ |
| 361 | static words() { |
| 362 | |
| 363 | // 转换 |
| 364 | let newWords = new Map |
| 365 | Object.keys(GM_getValue('key')).forEach(classesKey => { |
| 366 | |
| 367 | let info = GM_getValue('key')[classesKey].info |
| 368 | let words = GM_getValue('key')[classesKey].words |
| 369 | let color = GM_getValue('key')[classesKey].color |
| 370 | let limit = GM_getValue('key')[classesKey].limit |
| 371 | let textcolor = GM_getValue('key')[classesKey].textcolor |
| 372 | |
| 373 | words.forEach(word => { |
| 374 | let infoList = [] |
| 375 | |
| 376 | // 检测是否被多个类目包含,被多个类目包含的关键字会有对应类目的信息 |
| 377 | if (newWords.get(word + '')) { |
| 378 | infoList = newWords.get(word + '').infoList |
| 379 | infoList.push(info) |
| 380 | } else { |
| 381 | infoList = [info] |
| 382 | } |
| 383 | |
| 384 | newWords.set(word + '', { |
| 385 | classesKey, |
| 386 | infoList: infoList, |
| 387 | textcolor, |
| 388 | color, |
| 389 | limit |
| 390 | }) |
| 391 | }) |
nothing calls this directly
no outgoing calls
no test coverage detected