lib/defaults/index.js
function scrapTitle(window){
   var $ = window.$;
   var url = window.location.href;

   // Tags or attributes whom can contain a nice title for the page
   var titleTag =  $('title').text().trim();
   var metaTitleTag = $('meta[name="title"]').attr('content');
   var openGraphTitle = $('meta[property="og:title"]').attr('content');
   var h1Tag = $('h1').eq(0).text().trim();
   var itempropNameTag = $('[itemprop="name"]').text().trim();
   var titles = [titleTag, metaTitleTag, openGraphTitle, h1Tag, itempropNameTag];

   // Regex of the web site name
   var nameWebsite = utils.getWebsiteName(url);
   var regex = new RegExp(nameWebsite,'i');
   // Sort to find the best title
   var titlesNotEmpty = titles.filter(function(value){
      return !!value;
   });
   var titlesBest = titlesNotEmpty.filter(function(value){
      return !regex.test(value);
   });
   var bestTitle = (titlesBest && titlesBest[0]) || (titlesNotEmpty && titlesNotEmpty[0]) || '';
   return utils.inline(bestTitle);
}
function scrapTitle(window){
   var $ = window.$;
   var url = window.location.href;

   // Tags or attributes whom can contain a nice title for the page
   var titleTag =  $('title').text().trim();
   var metaTitleTag = $('meta[name="title"]').attr('content');
   var openGraphTitle = $('meta[property="og:title"]').attr('content');
   var h1Tag = $('h1').eq(0).text().trim();
   var itempropNameTag = $('[itemprop="name"]').text().trim();
   var titles = [titleTag, metaTitleTag, openGraphTitle, h1Tag, itempropNameTag];

   // Regex of the web site name
   var nameWebsite = utils.getWebsiteName(url);
   var regex = new RegExp(nameWebsite,'i');
   // Sort to find the best title
   var titlesNotEmpty = titles.filter(function(value){
      return !!value;
   });
   var titlesBest = titlesNotEmpty.filter(function(value){
      return !regex.test(value);
   });
   var bestTitle = (titlesBest && titlesBest[0]) || (titlesNotEmpty && titlesNotEmpty[0]) || '';
   return utils.inline(bestTitle);
}
function scrapTitle ( window ) { var $ = window . $ ; var url = window . location . href ; // Tags or attributes whom can contain a nice title for the page var titleTag = $ ( 'title' ) . text ( ) . trim ( ) ; var metaTitleTag = $ ( 'meta[name="title"]' ) . attr ( 'content' ) ; var openGraphTitle = $ ( 'meta[property="og:title"]' ) . attr ( 'content' ) ; var h1Tag = $ ( 'h1' ) . eq ( 0 ) . text ( ) . trim ( ) ; var itempropNameTag = $ ( '[itemprop="name"]' ) . text ( ) . trim ( ) ; var titles = [ titleTag , metaTitleTag , openGraphTitle , h1Tag , itempropNameTag ] ; // Regex of the web site name var nameWebsite = utils . getWebsiteName ( url ) ; var regex = new RegExp ( nameWebsite , 'i' ) ; // Sort to find the best title var titlesNotEmpty = titles . filter ( function ( value ) { return ! ! value ; } ) ; var titlesBest = titlesNotEmpty . filter ( function ( value ) { return ! regex . test ( value ) ; } ) ; var bestTitle = ( titlesBest && titlesBest [ 0 ] ) || ( titlesNotEmpty && titlesNotEmpty [ 0 ] ) || '' ; return utils . inline ( bestTitle ) ; }
Retrieve the more appropriate title of the page

@param  {Object} window -
@return {String}  title of the page
@api public
Retrieve the more appropriate title of the page