Comments (2)
Thank you for the suggestion. I'll have to think about it. The problem from my point of view is that if it's an option then the user risks creating a lot of profiles or changing the value of this option very often.
An interesting alternative for this use case is integration with userscripts. By enabling the hidden option userScriptEnabled
, see https://github.com/gildas-lormeau/SingleFile/wiki/Hidden-options, you can create a simple userscript that will be adapted to the page to be saved.
Here is below an example of such a script which is designed to save pages on "Le Monde" as https://www.lemonde.fr/international/article/2024/02/20/julian-assange-tente-d-obtenir-un-dernier-recours-contre-son-extradition-vers-les-etats-unis_6217460_3210.html
// ==UserScript==
// @name New Userscript
// @version 2024-02-20
// @author Gildas
// @match https://www.lemonde.fr/international/article/*
// @grant none
// ==/UserScript==
(() => {
"use strict";
dispatchEvent(new CustomEvent("single-file-user-script-init"));
addEventListener("single-file-on-before-capture-request", () => {
const element = document.querySelector(".zone--article");
isolateElement(element);
});
function isolateElement(element) {
const parentNode = element.parentNode;
Array.from(parentNode.childNodes).forEach(node => {
if (node != element) {
node.remove();
}
});
if (parentNode != document.body) {
isolateElement(parentNode);
}
}
})();
from singlefile.
I had an idea of using user scripts to prepare the page once I click a button, but custom events from a SingeFile are even better as no extra steps are required! I wasn't aware of custom events and hidden options. This will close my needs for now. Thanks for sharing! 👍
Regarding the script: where can I read why the extension needs a dispatchEvent()
from the user script?
UPD: found the answer here.
from singlefile.
Related Issues (20)
- Auto save on tab removal HOT 3
- Unable to edit page on mzh.moegirl.org.cn, blank in annotation editor with `Content Security Policy` errors (but open success, saved with smaller size) HOT 2
- Saving with Zip format (including SingleFileZ) fails to save some elements HOT 1
- The `white-space` attr will be removed after saving in Safari HOT 3
- Ability to run SingleFile within a Playwright context HOT 1
- Underlining of text HOT 1
- 保存网页后,本地html文件无法正常显示网页内容 HOT 3
- Re-save a folder as a self-extracting zip html file HOT 3
- This url is not being saved: http://dewbell.biz/en/products/water-pipe-love HOT 9
- SingelFile does not work on Android Microsoft Edge at all HOT 4
- Some tab / button trigger by js not working HOT 3
- feature request: debug log traces to be monitored in console HOT 4
- I'm bit confused about help page HOT 1
- Why can't I click this button,i want debug the crx! HOT 1
- ebay capture doesn't save all images HOT 1
- SingleFile freezes when saving with Zotero Connector enabled HOT 9
- Freeze on a Japanese website HOT 1
- 有些网址无法下载图片 HOT 1
- ScienceDirect snapshots are missing styles HOT 4
- Non-technical person here! Is it possible to save full websites with this? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from singlefile.