MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / initFilterObserver

Function initFilterObserver

filter.js:1962–1999  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1960
1961// 关键词过滤的 observer 初始化(用于主插件调用)
1962function initFilterObserver() {
1963
1964 // 检查是否有保存的关键词,如果有则自动应用过滤
1965 const whitelistKeywords = getKeywords(); // 显示关键词
1966 const blacklistKeywords = getCustomKeywords(); // 屏蔽关键词
1967 const highlightKeywords = getHighlightKeywords(); // 高亮关键词
1968
1969 // 总是应用过滤(无论是否有关键词),以确保统计数据显示
1970 // 延迟执行以确保页面元素(如.sorter)已加载
1971 setTimeout(() => {
1972 filterPosts(blacklistKeywords, whitelistKeywords);
1973 }, 100);
1974
1975 // 只有显示关键词时才自动显示过滤弹窗(保持位置)
1976 // 仅屏蔽关键词时不显示弹窗
1977 if (whitelistKeywords.length > 0) {
1978 // 延迟创建弹窗,确保页面完全加载
1979 setTimeout(() => {
1980 createFilterUI(); // 自动打开,恢复保存的位置
1981 }, 100);
1982 }
1983
1984 // 应用高亮关键词(无论是否有过滤关键词)
1985 if (highlightKeywords.length > 0) {
1986 // 延迟应用高亮,确保DOM完全加载
1987 setTimeout(() => {
1988 applyKeywordHighlight();
1989 }, 100);
1990
1991 // 也立即尝试应用一次
1992 applyKeywordHighlight();
1993 }
1994
1995 // 应用帖子内容高亮 (延迟以确保内容加载)
1996 setTimeout(() => {
1997 highlightPostContent();
1998 }, 500);
1999}
2000
2001// 拖动功能实现(与主插件一致,支持 window.makeDraggable)
2002if (!window.makeDraggable) {

Callers

nothing calls this directly

Calls 7

highlightPostContentFunction · 0.85
getKeywordsFunction · 0.70
getCustomKeywordsFunction · 0.70
getHighlightKeywordsFunction · 0.70
filterPostsFunction · 0.70
createFilterUIFunction · 0.70
applyKeywordHighlightFunction · 0.70

Tested by

no test coverage detected