File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 "build:mv3" : " webpack --config webpack.mv3.config.js --mode production" ,
1111 "build" : " yarn build:mv2 && yarn build:mv3" ,
1212 "postbuild" : " node scripts/firefox-fix.js" ,
13- "devbuild" : " webpack --mode development " ,
13+ "devbuild:mv3 " : " webpack --config webpack.mv3.config.js -- mode production --debug " ,
1414 "type-check" : " tsc --noEmit" ,
1515 "test" : " jest --testTimeout 20000" ,
1616 "test:watch" : " jest --watch" ,
Original file line number Diff line number Diff line change @@ -8,18 +8,36 @@ interface PostMessageEvent extends MessageEvent {
88 }
99}
1010
11+ function findFrameBySource ( source : MessageEventSource | null ) {
12+ const roots : Array < Document | ShadowRoot > = [ document ]
13+
14+ while ( roots . length ) {
15+ const root = roots . pop ( ) !
16+ const frame = Array . from (
17+ root . querySelectorAll < HTMLIFrameElement | HTMLFrameElement > (
18+ 'iframe, frame'
19+ )
20+ ) . find ( ( { contentWindow } ) => contentWindow === source )
21+
22+ if ( frame ) {
23+ return frame
24+ }
25+
26+ for ( const element of Array . from ( root . querySelectorAll ( '*' ) ) ) {
27+ if ( element . shadowRoot ) {
28+ roots . push ( element . shadowRoot )
29+ }
30+ }
31+ }
32+ }
33+
1134export function postMessageHandler ( { data, source } : PostMessageEvent ) {
1235 if ( ! data || data . type !== 'SALADICT_SELECTION' ) {
1336 return
1437 }
1538
16- // get the souce iframe
17- const matchSrc = ( { contentWindow } : HTMLIFrameElement | HTMLFrameElement ) =>
18- contentWindow === source
19-
20- const frame =
21- Array . from ( document . querySelectorAll ( 'iframe' ) ) . find ( matchSrc ) ||
22- Array . from ( document . querySelectorAll ( 'frame' ) ) . find ( matchSrc )
39+ // Search open shadow roots because reader frames may be nested inside one.
40+ const frame = findFrameBySource ( source )
2341
2442 if ( ! frame ) {
2543 return
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { whenKeyPressed, isQSKey } from './helper'
77/**
88 * Listen to triple-ctrl shortcut which opens quick search panel.
99 * Pressing ctrl/command key more than three times within 500ms
10- * trigers triple-ctrl.
10+ * triggers triple-ctrl.
1111 */
1212export function createQuickSearchStream ( config : AppConfig | null ) {
1313 if ( ! config || ! config . tripleCtrl || isStandalonePage ( ) || isOptionsPage ( ) ) {
You can’t perform that action at this time.
0 commit comments