Some tweaks
This commit is contained in:
parent
974fa1660a
commit
46fc5713eb
@ -41,9 +41,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.getElementById('sendButton').addEventListener('click', () => {
|
document.getElementById('sendButton').addEventListener('click', () => {
|
||||||
fetch(window.location + `?website=${document.getElementById("URL").value}`)
|
window.location = window.location + `?website=${document.getElementById("URL").value}`;
|
||||||
.then(res => tes.text())
|
|
||||||
.then(console.log);
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
7
index.js
7
index.js
@ -4,7 +4,7 @@ const fs = require("fs");
|
|||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
const { Remarkable } = require('remarkable-typescript');
|
const { Remarkable } = require('remarkable-typescript');
|
||||||
|
|
||||||
const client = new Remarkable({ token: process.env.REMARKABLE_TOKEN });
|
let token = process.env.REMARKABLE_TOKEN;
|
||||||
|
|
||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
const incomingURL = new URL(`http://localhost:8000${req.url}`);
|
const incomingURL = new URL(`http://localhost:8000${req.url}`);
|
||||||
@ -67,7 +67,7 @@ async function sendPage(website, tries = 0) {
|
|||||||
try {
|
try {
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.emulate(Object.assign({}, puppeteer.devices["iPad Pro"], { userAgent: "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" }));
|
await page.emulate(Object.assign({}, puppeteer.devices["iPad Pro"], { userAgent: "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" }));
|
||||||
await page.goto(website.toString());
|
await page.goto(website.toString(), { referer: "https://www.google.com/" });
|
||||||
const title = await page.title()
|
const title = await page.title()
|
||||||
console.log("Page loaded. Title - " + title)
|
console.log("Page loaded. Title - " + title)
|
||||||
|
|
||||||
@ -80,9 +80,10 @@ async function sendPage(website, tries = 0) {
|
|||||||
})
|
})
|
||||||
} );
|
} );
|
||||||
|
|
||||||
const myPDF = await page.pdf({ format: 'A3' });
|
const myPDF = await page.pdf({ format: 'A3', margin: {top: 5, bottom: 5} });
|
||||||
console.log("Saved to PDF")
|
console.log("Saved to PDF")
|
||||||
|
|
||||||
|
const client = new Remarkable({ token });
|
||||||
await client.uploadPDF(title, myPDF);
|
await client.uploadPDF(title, myPDF);
|
||||||
console.log("Uploaded to reMarkable");
|
console.log("Uploaded to reMarkable");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user