I'm trying to create a chrome extension that gives the user a reader mode and removes the unnecessary parts of the page. I tried to use readability.js and mercury for web parsing but for some reason they're not working and I couldn't import them correctly. For example for readability, when I alert the "read" object, it is there:
However when I try the example in the docs:
read('http://howtonode.org/really-simple-file-uploads', function (err, article, meta) {
// Main Article
console.log(article.content);
// Title
console.log(article.title);
// HTML Source Code
console.log(article.html);
// DOM
console.log(article.document);
// Response Object from Request Lib
console.log(meta);
// Close article to clean up jsdom and prevent leaks
article.close();
});
it won't work, and the console shows the error:
readability.js:1 Uncaught ReferenceError: require is not defined
at readability.js:1
which is because of the node syntax in the library files:
var jsdom = require('jsdom');
var request = require('request');
var helpers = require('./helpers');
var encodinglib = require("encoding");
var urllib = require('url');
...
I tried Mercury and it has the same problem. Is there any solution or a client side alternative for web parsing?