简体   繁体   中英

Detect anchor in Chrome Extension manifest.json

I'm trying to make a chrome extension, and i need it to apply a script if the URL is https://accounts.google.com/........#identifier But this isnt working
Why?

manifest.json

"content_scripts": [{
    "matches": ["https://accounts.google.com/*#identifier"],
    "js": ["myJS.js"]
}]

For url containing anchor ( # ), the web request actually is still sent to https://accounts.google.com/ without the part after # , so your match pattern won't match what you want.

You could set "matches": ["https://account.google.com/*"] here and wrap your method inside window.onhashchange listener, in that method, to detect if location.hash === "#identifier" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM