CryptalEquine / Howrse Close Button

// ==UserScript==
// @name          Howrse Close Button
// @namespace     cryptal
// @description   For Howrse: Adds a button to close the tab, next to the bed button
// @author        CryptalEquine
// @include       */elevage/chevaux/cheval?id=*
// @version       1.1.1
// @run-at        document-start
// @noframes      true
// @grant         GM_log
// @license       MIT
// @require       https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @require       https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @updateURL     https://openuserjs.org/meta/CryptalEquine/Howrse_Close_Button.meta.js
// ==/UserScript==

waitForKeyElements("#night-tab-main", Add, false);

function Add(e)
{
   var div = $(e).find("div[class*='grid-cell odd middle  width-33']");
   var s = '<a href="javascript:;" id="close" class="action action-style-4 coucher-box"><span class="text new-console">Close</span></a>';
   div.html(s);
   $("#close").click( function() { window.close(); } );
}