tasks/dentist.js
function parse_html() {
      var reading_js = false, reading_css = false;
      var parser = new htmlparser.Parser({
        onopentag: function(name, attribs){
          if (name === "script" && ! attribs.src && (attribs.type === "text/javascript" || ! attribs.type)){
            reading_js = true;
          }
          else if (name === "style") {
            reading_css = true;
          }
        },
        ontext: function(text){
          if (reading_js) {
            scripts.push(text);
          }
          if (reading_css) {
            styles.push(text);
          }
        },
        onclosetag: function(tagname){
          if (tagname === "script"){
            reading_js = false;
          }
          else if (tagname === "style"){
            reading_css = false;
          }
        }
      });
      parser.write(src);
      parser.end();

      return true;
    }
function parse_html() {
      var reading_js = false, reading_css = false;
      var parser = new htmlparser.Parser({
        onopentag: function(name, attribs){
          if (name === "script" && ! attribs.src && (attribs.type === "text/javascript" || ! attribs.type)){
            reading_js = true;
          }
          else if (name === "style") {
            reading_css = true;
          }
        },
        ontext: function(text){
          if (reading_js) {
            scripts.push(text);
          }
          if (reading_css) {
            styles.push(text);
          }
        },
        onclosetag: function(tagname){
          if (tagname === "script"){
            reading_js = false;
          }
          else if (tagname === "style"){
            reading_css = false;
          }
        }
      });
      parser.write(src);
      parser.end();

      return true;
    }
function parse_html ( ) { var reading_js = false , reading_css = false ; var parser = new htmlparser . Parser ( { onopentag : function ( name , attribs ) { if ( name === "script" && ! attribs . src && ( attribs . type === "text/javascript" || ! attribs . type ) ) { reading_js = true ; } else if ( name === "style" ) { reading_css = true ; } } , ontext : function ( text ) { if ( reading_js ) { scripts . push ( text ) ; } if ( reading_css ) { styles . push ( text ) ; } } , onclosetag : function ( tagname ) { if ( tagname === "script" ) { reading_js = false ; } else if ( tagname === "style" ) { reading_css = false ; } } } ) ; parser . write ( src ) ; parser . end ( ) ; return true ; }
Use the HTML parser to grab anything inside script and style tags.
Use the HTML parser to grab anything inside script and style tags .