Repository: rhysd/monolith-of-web
Branch: master
Commit: 9a69d2153ad9
Files: 24
Total size: 27.5 KB
Directory structure:
gitextract_vft5ts7_/
├── .eslintrc.json
├── .github/
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── .gitmodules
├── .prettierrc.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── background.html
├── background.ts
├── bootstrap.ts
├── content.ts
├── lib.d.ts
├── manifest.json
├── package.json
├── popup.css
├── popup.html
├── popup.ts
├── resources/
│ └── icon.xcf
├── storage.ts
├── tsconfig.json
├── tsconfig.webpack.json
└── webpack.config.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.json
================================================
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"ignorePatterns": [
"webpack.config.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint",
"prettier"
],
"env": {
"es6": true,
"browser": true,
"node": true
},
"globals": {
"chrome": "readonly"
},
"rules": {
"prefer-spread": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"eqeqeq": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/prefer-readonly": "error"
}
}
================================================
FILE: .github/workflows/ci.yml
================================================
name: CI
on: [push, pull_request]
jobs:
check:
name: Try build and apply eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/setup-node@v1
- run: npm ci
- run: npm run build
- run: npm run lint
================================================
FILE: .gitignore
================================================
/node_modules
/dist
================================================
FILE: .gitmodules
================================================
[submodule "monolith"]
path = monolith
url = https://github.com/rhysd/monolith.git
================================================
FILE: .prettierrc.json
================================================
{
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
================================================
FILE: CHANGELOG.md
================================================
# [v0.1.2](https://github.com/rhysd/monolith-of-web/releases/tag/v0.1.2) - 12 Jan 2020
- **Fix:** Handle CORS more properly
- **Improve:** Update upstream monolith repo
[Changes][v0.1.2]
# [v0.1.1](https://github.com/rhysd/monolith-of-web/releases/tag/v0.1.1) - 03 Jan 2020
- **Improve:** Insecure permissions are no longer necessary. They were removed from permissions list and now only `activeTab` is required
[Changes][v0.1.1]
# [v0.1.0](https://github.com/rhysd/monolith-of-web/releases/tag/v0.1.0) - 02 Jan 2020
First release :tada:
[Changes][v0.1.0]
[v0.1.2]: https://github.com/rhysd/monolith-of-web/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/rhysd/monolith-of-web/compare/v0.1.0...v0.1.1
[v0.1.0]: https://github.com/rhysd/monolith-of-web/tree/v0.1.0
================================================
FILE: CONTRIBUTING.md
================================================
Thank you for contributing this repository!
Before contributing, please read 'Contributing' section of [README.md](./README.md).
https://github.com/rhysd/monolith-of-web/blob/master/README.md#contributing
================================================
FILE: LICENSE
================================================
Copyright (c) 2019 rhysd
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
'Monolith of Web': Chrome Extension Port of [Monolith][1]
=========================================================
['Monolith of Web'][6] is a Chrome extension ported from CLI tool [Monolith][1]. Monolith is a CLI tool to
download a web page as static single HTML file. 'Monolith of Web' provides the same functionality as
a browser extension by compiling Monolith (written in Rust) into WebAssembly.

## Installation
- Install from [Chrome Web Store][7]
- Download `.crx` file from [releases page][5] and install it manually
## Usage

1. Go to a web page you want to store
2. Click 'Monolith of Web' icon in a browser bar (above popup window will open)
3. Click 'Get Monolith' button
4. Wait for the process completing
5. The generated single static HTML file is stored in your downloads folder
By toggling icons at bottom of the popup window, you can determine to or not to include followings
in the generated HTML file.
- JavaScript
- CSS
- ``
- Images
The button at right-bottom toggles if allow CORS request or not. Please read following 'Permissions'
section and 'CORS Requests in Background Page' section for more details.
## Permissions
- **Required permissions**
- `activeTab`: This extension gets an HTML text and a page title from the active tab to generate a monolith
- `storage`: This extension remembers the last state of toggle buttons at bottom in the popup window.
- **Optional permissions**
- `http://*/*` and `https://*/*`: Allow any cross-origin requests in background page. This is runtime
permission so this extension does not require by default. **Only when you see a broken HTML file is
generated due to CORS error in background page, please enable this option.** The reason of these
permissions are explained in next 'CORS Requests in Background Page' section.
## CORS Requests in Background Page
This extension generates a single HTML file in background page of Chrome extension. Since CSP in a
content script is not applied in a background page, some resources in content's HTML cannot be fetched
in background page.
By default, this extension ignores CORS errors in background page. It is usually not a problem since
resources protected by CSP are usually scripts which don't affect main content. But a broken single HTML
page may be generated due to CORS errors.
When you see a broken page due to the CORS error in background page, please enable 'allow CORS requests'
button at right-bottom in the popup window. Permission dialog will appear to require permissions for
sending CORS requests in background page. After accepting it, CORS request error is disabled and all
resources should be fetched with no error.
After generating a single HTML file with the runtime permissions, this extension will remove the permissions
as soon as possible for security.
## Development
WebAssembly port of Monolith is developed in [the forked repository][4]. Currently it has some differences
and duplicates against the original repository. reqwest did not support Wasm before 0.10.0 so my Wasm
port does not use it and uses `fetch()` directly via `js_sys` and `web_sys` crate.
This repository adds the forked Monolith repository as a Git submodule and uses it by bundling sources
with Webpack.
## Contributing
### Creating an issue
Before reporting an issue, please try the same URL with [CLI version][1]. If it is reproducible with
CLI version, please report it to the CLI repository at first.
If it is not reproducible with CLI version (it means the issue only occurs with this extension), please
report it from [issues page][8].
### Improve Wasm part
This repository only includes TypeScript part of extension. Wasm part is developed in
[forked monolith repository][4]. If your improvement can be applied to [upstream][1], please make a
pull request in the upstream at first. After the pull request is merged, please make an issue to
request to merge upstream at this repository or the forked repository.
## License
Distributed under [the MIT license](LICENSE).
[1]: https://github.com/Y2Z/monolith
[3]: https://chrome.google.com/webstore/detail/koalogomkahjlabefiglodpnhhkokekg
[4]: https://github.com/rhysd/monolith
[5]: https://github.com/rhysd/monolith-of-web/releases
[6]: https://github.com/rhysd/monolith-of-web
[7]: https://chrome.google.com/webstore/detail/monolith/koalogomkahjlabefiglodpnhhkokekg
[8]: https://github.com/rhysd/monolith-of-web/issues
================================================
FILE: background.html
================================================