Skip to main content
1 of 2
ᔕᖺᘎᕊ
  • 4.4k
  • 2
  • 16
  • 37

##Oneboxing etymonline definitions

customSites['etymonline.com'] = function(link, $obj) {
    var term = link.split('?')[1].split('term=')[1];
    if(term) {
    $('head').append('<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/shu8/SE-Chat-Custom-Oneboxes/master/etymonline.css">');
        $.get("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22" + encodeURIComponent('http://etymonline.com/index.php?term=' + term) + "%22&callback=", function(d) {
            var termToDisplay = $(d).find('#dictionary dt:eq(0)').text(),
                definition = $(d).find('#dictionary dd:eq(0)').text();

            var template = "<div class='etymonline-container'>\
                              <span class='term'>[etymonline]: <a href='"+link+"'>" + termToDisplay + "</a></span><br>\
                              <span>" + definition + "</span>\
                            </div>";

            $obj.html(template);
        });
    }
};
ᔕᖺᘎᕊ
  • 4.4k
  • 2
  • 16
  • 37