@@ -313,7 +313,7 @@ function tianliGPT(usePjax) {
313313
314314 function checkURLAndRun ( ) {
315315 if ( typeof tianliGPT_postURL === "undefined" ) {
316- runTianliGPT ( ) ; // 如果没有设置自定义 URL,则直接执行 runTianliGPT() 函数
316+ tianliGPTCustomBlackList ( ) ; // 如果没有设置自定义 URL,则直接执行 runTianliGPT() 函数
317317 return ;
318318 }
319319
@@ -330,7 +330,7 @@ function tianliGPT(usePjax) {
330330 const currentURL = window . location . href ;
331331
332332 if ( urlPattern . test ( currentURL ) ) {
333- runTianliGPT ( ) ; // 如果当前 URL 符合用户设置的 URL,则执行 runTianliGPT() 函数
333+ tianliGPTCustomBlackList ( ) ; // 如果当前 URL 符合用户设置的 URL,则执行 runTianliGPT() 函数
334334 } else {
335335 console . log ( "TianliGPT:因为不符合自定义的链接规则,我决定不执行摘要功能。" ) ;
336336 }
@@ -339,6 +339,32 @@ function tianliGPT(usePjax) {
339339 }
340340 }
341341
342+ function tianliGPTCustomBlackList ( ) {
343+ if ( typeof tianliGPT_blacklist === "undefined" ) {
344+ runTianliGPT ( ) ; // 如果没有设置自定义 URL,则直接执行 runTianliGPT() 函数
345+ return ;
346+ } else {
347+ // 使用 fetch 请求 JSON 文件
348+ fetch ( tianliGPT_blacklist )
349+ . then ( response => response . json ( ) )
350+ . then ( data => {
351+ const urlList = data . urls ; // 假设 JSON 文件中有一个 urls 键
352+ let currentPageUrl = window . location . href ;
353+ let isBlacklisted = urlList . some ( pattern => {
354+ // 将通配符转换为正则表达式
355+ let regex = new RegExp ( "^" + pattern . replace ( / \* / g, ".*" ) + "$" ) ;
356+ return regex . test ( currentPageUrl ) ;
357+ } ) ;
358+
359+ // 如果当前页面 URL 不在黑名单中,则执行 tianliGPT
360+ if ( ! isBlacklisted ) {
361+ runTianliGPT ( ) ;
362+ }
363+ } )
364+ . catch ( error => console . error ( 'Error fetching blacklist:' , error ) ) ;
365+ }
366+ }
367+
342368 if ( usePjax ) {
343369 checkURLAndRun ( ) ;
344370 } else {
0 commit comments