File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,38 @@ if (typeof Storage !== "undefined" && isDashboardOrigin()) {
3838 } ;
3939}
4040
41+ // Announce extension presence to the dashboard so it can hide the "install
42+ // the extension" nudge. window.postMessage crosses the content-script /
43+ // page-world boundary; the message is scoped to the page's own origin.
44+ if ( typeof window !== "undefined" && isDashboardOrigin ( ) ) {
45+ const announcePresence = ( ) => {
46+ try {
47+ window . postMessage (
48+ {
49+ source : "subturtle-extension" ,
50+ type : "presence" ,
51+ version : chrome . runtime . getManifest ( ) . version ,
52+ } ,
53+ window . location . origin
54+ ) ;
55+ } catch ( _e ) {
56+ // postMessage can fail in odd sandboxed iframes — non-fatal.
57+ }
58+ } ;
59+
60+ // Announce immediately in case the dashboard listener is already attached.
61+ announcePresence ( ) ;
62+
63+ // Respond to dashboard pings in case the dashboard mounts after us.
64+ window . addEventListener ( "message" , ( event ) => {
65+ if ( event . source !== window ) return ;
66+ const data = event . data ;
67+ if ( data ?. source === "subturtle-dashboard" && data ?. type === "ping" ) {
68+ announcePresence ( ) ;
69+ }
70+ } ) ;
71+ }
72+
4173import { GlobalOptions , authentication } from "@modular-rest/client" ;
4274
4375import { sendMessage , sendMessageToTabs } from "../common/helper/massage" ;
You can’t perform that action at this time.
0 commit comments