1

I am trying to create a browser extension which parses url's shown on a particular webpage, matches these urls against a database of safe urls, and then shows an alert to the user when they click on an unsafe link. I got the parsing (reading of html) of the urls to work using node.js and cheerio, but I don't know how to alter the html/add javascript to the existing webpage. What javascript framework should I use to load the current user's browser webpage and add javascript to it? Thanks!

EDIT: I parsed the links using:

request(url, function(err, resp, body) {
    $ = cheerio.load(body);
    links = $('a'); //jquery get all hyperlinks)

    $(links).each(function (i, link) {
        var parsed_url = $(link).attr('href').split("/");
        var parsed_url_no_www = parsed_url[2]
        if (parsed_url_no_www.includes('www')) parsed_url_no_www = parsed_url_no_www.substring(parsed_url_no_www.indexOf('.') + 1)                                request(url, function(err, resp, body) {
    $ = cheerio.load(body);
    links = $('a'); //jquery get all hyperlinks)

    $(links).each(function (i, link) {
        var parsed_url = $(link).attr('href').split("/");
        var parsed_url_no_www = parsed_url[2]
        if (parsed_url_no_www.includes('www')) parsed_url_no_www = parsed_url_no_www.substring(parsed_url_no_www.indexOf('.') + 1)
  • I am insterested in your work. How exactly did you ".. got the parsing (reading of html) of the urls to work using node.js"? – marko-36 May 9 '19 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.