-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
How to integrate SingleFile library code in "custom" environments?
Gildas edited this page Apr 28, 2022
·
30 revisions
-
Execute the scripts below ideally before any other script (e.g. before the HTML document is parsed).
-
in the top window:
lib/single-file-bootstrap.js
-
in frames and the top window:
lib/single-file-frames.js
-
-
Execute the script below in the top window, before saving the page.
lib/single-file.js
-
Execute the script below in the top window. See here for more information about the syntax https://github.com/gildas-lormeau/SingleFile/wiki/How-to-integrate-the-API-of-SingleFile-into-an-extension.
const { content, title, filename } = await singlefile.getPageData({
removeHiddenElements: true,
removeUnusedStyles: true,
removeUnusedFonts: true,
removeImports: true,
removeScripts: true,
compressHTML: true,
removeAudioSrc: true,
removeVideoSrc: true,
removeAlternativeFonts: true,
removeAlternativeMedias: true,
removeAlternativeImages: true,
groupDuplicateImages: true
});
- You might also need to pass the
fetch
option if you need to bypass CORS or other security restrictions. The value of this property is a function which implementsfetch
.