-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathbookmarkletInject.ts
35 lines (29 loc) · 1.31 KB
/
bookmarkletInject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
declare var bookmarkletRoot: string;
import {IFrameMessageHandler} from "../../communicator/iframeMessageHandler";
import {ClipperInject, ClipperInjectOptions} from "../../extensions/clipperInject";
import {DebugLoggingInject} from "../../extensions/debugLoggingInject";
import {UnsupportedBrowserInject} from "../../extensions/unsupportedBrowserInject";
import {BrowserUtils} from "../../browserUtils";
import {InjectHelper} from "../injectHelper";
if (BrowserUtils.browserNotSupported()) {
UnsupportedBrowserInject.main();
} else if (InjectHelper.isKnownUninjectablePage(self.location.href)) {
InjectHelper.alertUserOfUnclippablePage();
} else {
let clipperUrl = bookmarkletRoot + "/clipper.html";
let options: ClipperInjectOptions = {
frameUrl: clipperUrl,
enableAddANote: false,
enableEditableTitle: false,
enableRegionClipping: false,
useInlineBackgroundWorker: true
};
// We don't pass a messageHandler for the background Extension since we set useInlineBackgroundWorker above
let clipperInject = ClipperInject.main(options);
// We need to pass the frame of the Clipper into the debug logging inject code as that's where the extension lives
DebugLoggingInject.main({
extMessageHandlerThunk: () => {
return new IFrameMessageHandler(() => { return clipperInject.getFrame().contentWindow; });
}
});
}