File tree Expand file tree Collapse file tree 2 files changed +22
-21
lines changed
Expand file tree Collapse file tree 2 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -33,18 +33,13 @@ export default {
3333} ;
3434
3535export const shared = {
36- toggleNewFeed : async function ( willShow , tabId ) {
37- runScriptInTab ( {
38- tabId : tabId || ( await getCurrentTab ( ) ) . id ,
39- args : [ willShow ] ,
40- func : ( value ) => {
41- let div = document . querySelector ( "#ssrb_feed_end" ) ?. parentElement ;
42- if ( ! div ) alert ( "Không tìm thấy NewFeed." ) ;
43- else {
44- div . style . display =
45- value ?? div . style . display === "none" ? "block" : "none" ;
46- }
47- } ,
48- } ) ;
36+ toggleNewFeed : async function ( willShow ) {
37+ let div = document . querySelector ( "#ssrb_feed_end" ) ?. parentElement ;
38+ if ( ! div ) alert ( "Không tìm thấy NewFeed." ) ;
39+ else if ( willShow != null ) {
40+ div . style . display = willShow ? "block" : "none" ;
41+ } else {
42+ div . style . display = div . style . display === "none" ? "block" : "none" ;
43+ }
4944 } ,
5045} ;
Original file line number Diff line number Diff line change @@ -162,15 +162,21 @@ export function checkBlackWhiteList(script, url) {
162162 return willRun ;
163163}
164164
165+ // https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API
165166export function isUrlMatchPattern ( url , pattern ) {
166- let curIndex = 0 ,
167- visiblePartsInPattern = pattern . split ( "*" ) . filter ( ( _ ) => _ !== "" ) ;
168- for ( let p of visiblePartsInPattern ) {
169- let index = url . indexOf ( p , curIndex ) ;
170- if ( index < 0 ) return false ;
171- curIndex = index + p . length ;
172- }
173- return true ;
167+ return new URLPattern ( pattern ) . test ( url ) ;
168+
169+ // if (pattern.indexOf("*") < 0)
170+ // return new URL(url).toString() == new URL(pattern).toString();
171+
172+ // let curIndex = 0,
173+ // visiblePartsInPattern = pattern.split("*").filter((_) => _ !== "");
174+ // for (let p of visiblePartsInPattern) {
175+ // let index = url.indexOf(p, curIndex);
176+ // if (index < 0) return false;
177+ // curIndex = index + p.length;
178+ // }
179+ // return true;
174180}
175181
176182// https://stackoverflow.com/a/68634884/11898496
You can’t perform that action at this time.
0 commit comments