#!/usr/bin/env node // // # Description // // Summarize the current page in a new tab, by processing it with the standalone readability // library used for Firefox Reader View. // // # Prerequisites // // - Mozilla's readability library (npm install -g @mozilla/readability) // - Also available in the AUR as nodejs-readability-git // - jsdom (npm install -g jsdom) // - qutejs (npm install -g qutejs) // // - Ensure that node knows where to find your globally installed modules by adding // the following to ~/.profile or /etc/profile: // // export NODE_PATH=$NODE_PATH:$(npm root -g) // // *Note*: On some Linux distros and macOS, it may be easier to set NODE_PATH using qutebrowser's // qt.environ setting. For instance, if 'npm root -g' returns /usr/lib/node_modules, then run: // // :set qt.environ '{"NODE_PATH": "/usr/lib/node_modules"}' // // # Usage // // :spawn --userscript readability-js // // One may wish to define an easy to type command alias in qutebrowser's configuration file: // c.aliases = {"readability" : "spawn --userscript readability-js", ...} const { Readability } = require('@mozilla/readability'); const qute = require('qutejs'); const JSDOM = require('jsdom').JSDOM; const fs = require('fs'); const path = require('path'); const util = require('util'); const HEADER = `