MCPcopy
hub / github.com/ocsjs/ocsjs / titleTransform

Function titleTransform

packages/scripts/src/projects/icourse.ts:482–500  ·  view source on GitHub ↗
(titles: (HTMLElement | undefined)[])

Source from the content-addressed store, hash-verified

480 });
481
482 const titleTransform = (titles: (HTMLElement | undefined)[]) => {
483 return removeRedundantWords(
484 titles
485 .filter((t) => t?.innerText || t?.querySelector('img'))
486 .map((t) => {
487 if (t) {
488 const el = optimizationElementWithImage(t, true);
489 // textContent can still read the hidden image URL placeholders.
490 return (el.textContent || '').replace(/\s+/g, ' ').trim() || '';
491 }
492 return '';
493 })
494 .filter((t) => t.trim() !== '')
495 .join(',')
496 // /\u200B/g 排除不可见的空格
497 .replace(/[\u200A-\u200F]/g, ''),
498 redundanceWordsText.split('\n')
499 );
500 };
501 const work_type = type;
502
503 /** 新建答题器 */

Callers 1

workAndExamFunction · 0.70

Calls 2

removeRedundantWordsFunction · 0.90

Tested by

no test coverage detected