| Hash | Commit message | Author | Date | Files | + | - |
1 | commit 06306162791e0da55ba8944a12968e0f8e1426ce |
2 | Author: Connor Etherington <[email protected]> |
3 | Date: Sat Sep 14 01:54:10 2024 +0200 |
4 | |
5 | Auto-Commit Update - 20240914 |
6 | --- |
7 | PKGBUILD | 12 +++--------- |
8 | app.js | 45 +++++++++++++++++++++++---------------------- |
9 | 2 files changed, 26 insertions(+), 31 deletions(-) |
10 | |
11 | diff --git a/PKGBUILD b/PKGBUILD |
12 | index 69e3f2a..8fa261a 100644 |
13 | --- a/PKGBUILD |
14 | +++ b/PKGBUILD |
15 | @@ -9,15 +9,9 @@ url="https://gitlab.com/a4to/${pkgname}" |
16 | license=('MIT') |
17 | depends=(nodejs npm) |
18 | makedepends=(nodejs npm) |
19 | -source=( |
20 | - "https://software.concise.cc/x86_64/${pkgname}-${pkgver}-${pkgrel}-$arch.pkg.tar.xz" |
21 | -) |
22 | -sha512sums=( |
23 | - 'f7fe153371d23665268cbcbba1506a26db3e388b326ba95256ab4d32ae80d4b8f330a323b6d48e9ea01466eb5dc81f56c9219b4caca52fe86c388ff96879bd7f' |
24 | -) |
25 | -md5sums=( |
26 | - 'b2d627d1120af79bf3821d76467a02e0' |
27 | -) |
28 | +source=(https://gitlab.com/a4to/get/-/archive/${pkgver}/get-${pkgver}.tar.gz) |
29 | +md5sums=('SKIP') |
30 | +sha256sums=('SKIP') |
31 | validpgpkeys=( |
32 | '81BACEEBC3EA26E127166E4A819BB92A9A48160E' |
33 | ) |
34 | diff --git a/app.js b/app.js |
35 | index fc83e25..2d238b4 100755 |
36 | --- a/app.js |
37 | +++ b/app.js |
38 | @@ -14,6 +14,15 @@ const yargs = require('yargs'); |
39 | const cheerio = require('cheerio'); |
40 | let puppeteer; |
41 | |
42 | +const log = (input, ...args) => { |
43 | + const colors = { |
44 | + r: '\x1b[31;1m', g: '\x1b[32;1m', b: '\x1b[34;1m', y: '\x1b[33;1m', w: '\x1b[37;1m', |
45 | + m: '\x1b[35;1m', x: '\x1b[38;2;103;208;168m', c: '\x1b[36;1m', C: '\x1b[0m' }; |
46 | + input = input.concat(':C: ', ...args).toString(); |
47 | + let result = input.replace(/:([rgbyxwmcC]):/g, (match, p1) => colors[p1] || ''); |
48 | + console.log(result + colors.C); |
49 | +}; |
50 | + |
51 | const { JSDOM } = require('jsdom'); |
52 | |
53 | class Page { |
54 | @@ -96,32 +105,24 @@ class Scraper { |
55 | if (!puppeteer) { |
56 | puppeteer = require('puppeteer-extra'); |
57 | const pluginStealth = require('puppeteer-extra-plugin-stealth'); |
58 | - const puppeteer = require('puppeteer-extra'); |
59 | const userPrefs = require('puppeteer-extra-plugin-user-preferences'); |
60 | - puppeteer.use(userPrefs({ userPreferences: {/* your custom prefs */}})); |
61 | + puppeteer.use(userPrefs({ userPrefs: { webkit: { webprefs: { experimentalFeatures: true } } } })); |
62 | puppeteer.use(pluginStealth()); |
63 | } |
64 | |
65 | - const launchOptions = { |
66 | - headless: true, |
67 | - args: [ |
68 | - '--no-sandbox', |
69 | - '--disable-setuid-sandbox', |
70 | - '--disable-infobars', |
71 | - '--window-position=0,0', |
72 | - '--ignore-certifcate-errors', |
73 | - '--ignore-certifcate-errors-spki-list', |
74 | - '--disable-web-security', |
75 | - '--disable-site-isolation-trials', |
76 | - '--ignore-gpu-blacklist', |
77 | - '--ignore-certificate-errors', |
78 | - '--disable-dev-shm-usage', |
79 | - '--disable-accelerated-2d-canvas', |
80 | - '--disable-gpu', |
81 | - '--no-first-run', |
82 | - '--no-zygote' |
83 | - ] |
84 | - }; |
85 | + let executablePath = require('puppeteer').executablePath(); |
86 | + if(!fs.existsSync(executablePath)) { |
87 | + log(`:y:? :x:Puppeteer executable not found. Attempting to install...`); |
88 | + try { |
89 | + await require('child_process').execSync('npx puppeteer browsers install'); |
90 | + executablePath = require('puppeteer').executablePath(); |
91 | + } catch (error) { |
92 | + log(`:r:- :x:Failed to install Puppeteer executable. Please install manually.`); |
93 | + process.exit(1); |
94 | + } |
95 | + } |
96 | + |
97 | + const launchOptions = { executablePath }; |
98 | |
99 | const browser = await puppeteer.launch(launchOptions); |
100 | const page = await browser.pages().then(pages => pages[0]); |