<commit_before>/*
 * Yahoo search pagemod functions
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Cleanbits/The Green Web Foundation 2010-2017
 */

/**
 * On Request, find all hrefs and assign green or grey icon
 */
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request.data) {
            var data = request.data;
            var list = $("#web").find("ol > li");

            list.each(function () {
              var loc = getUrl($(this).find('a').first().attr('href'));
                if (loc && data[loc]) {
                  $(this).find('.TGWF').first()
                    .html(getResultNode(data[loc]).append('&nbsp;'))
                    .qtip({
                      content: { 
                        text: function(api) { 
                          return getTitleWithLink(data[loc]); 
                          }
                        },
                      show: { delay: 700 },
                      hide: { fixed:true,  delay:500 }
                    });
                  if(data[loc].green){
                    $(this).find('.TGWF').first().qtip('option', { 'style.classes': 'qtip-green'});
                  } else {
                    $(this).find('.TGWF').first().qtip('option', { 'style.classes': 'qtip-light'});
                  }                
                }
            });
        }
    });

/**
 * If document is ready, find the urls to check
 */
$(document).ready(function() {
    chrome.storage.local.get("tgwf_search_disabled", function(items) {
        if(items && items.tgwf_search_disabled && items.tgwf_search_disabled === 1){
          // Green web search is disabled, return
          return;
        }

        $('#ft').prepend("<p id='thegreenweb'>" + getLinkImage('green','The Green Web extension shows if a site is sustainably hosted') + ' The Green Web is enabled</p>');
        
        var locs = {};
        var list = $("#web").find("ol > li");
        if (list.length > 0) {
             list.each(function (i) {
                 $(this).find('.url').parent().first().children().first().prepend($('<span>', { class: 'TGWF'}).append(getImageNode('greenquestion')).append('&nbsp;'));
                 var loc = getUrl($(this).find('a').first().attr('href'));
                 locs[loc] = loc;
             });
        }

        if (Object.keys(locs).length > 0) {
            chrome.runtime.sendMessage({locs: locs}, function(response) {});
        }
    });
});<commit_msg>fix(yahoo): Fix yahoo page searchmod<commit_after>/*
 * Yahoo search pagemod functions
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Cleanbits/The Green Web Foundation 2010-2017
 */

/**
 * On Request, find all hrefs and assign green or grey icon
 */
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        if (request.data) {
            var data = request.data;
            var list = $("#web").find("ol > li");

            list.each(function () {
              var loc = getUrl($(this).find('a').first().attr('href'));
                if (loc && data[loc]) {
                  $(this).find('.TGWF').first()
                    .html(getResultNode(data[loc]).append('&nbsp;'))
                    .qtip({
                      content: { 
                        text: function(api) { 
                          return getTitleWithLink(data[loc]); 
                          }
                        },
                      show: { delay: 700 },
                      hide: { fixed:true,  delay:500 }
                    });
                  if(data[loc].green){
                    $(this).find('.TGWF').first().qtip('option', { 'style.classes': 'qtip-green'});
                  } else {
                    $(this).find('.TGWF').first().qtip('option', { 'style.classes': 'qtip-light'});
                  }                
                }
            });
        }
    });

/**
 * If document is ready, find the urls to check
 */
$(document).ready(function() {
    chrome.storage.local.get("tgwf_search_disabled", function(items) {
        if (items && items.tgwf_search_disabled && items.tgwf_search_disabled === 1) {
          // Green web search is disabled, return
          return;
        }

        // Remove all tgwf links
        $('#thegreenweb').remove();

        $('#ft').prepend("<p id='thegreenweb'>" + getLinkImage('green','The Green Web extension shows if a site is sustainably hosted') + ' The Green Web is enabled</p>');
        
        var locs = {};
        var list = $("#web").find("ol > li");
        if (list.length > 0) {
            // Remove all tgwf links
            $('.TGWF').remove();

             list.each(function (i) {
                 $(this).find('a').parent().first().children().first().prepend($('<span>', { class: 'TGWF'}).append(getImageNode('greenquestion')).append('&nbsp;'));
                 var loc = getUrl($(this).find('a').first().attr('href'));
                 locs[loc] = loc;
             });
        }

        if (Object.keys(locs).length > 0) {
            chrome.runtime.sendMessage({locs: locs}, function(response) {});
        }
    });
});
{'fraction_non_alphanumeric': 0.17215189873417722, 'fraction_numerical': 0.006621226874391432, 'mean_word_length': 1.6031424227065383, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5601461', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1377, 'n_words': 281}