User:Saftzie/Beta.js

(function {  'use strict';

/* sort order: --- Disguise: Polar Bear > Invisible > other Points: 3 > 1 (2) > 1 Requirement: other > None Location: Wilderness > other

Options: Twins/Triplets/etc. Snowman/Pumpkin

var isReady = false;

function onClick {   alert('Ouch!'); // soon to be something useful }

$(function main {    var domTable = document.getElementById('pengData');

var domButtonCell, domButton;

if (isReady) {     return; }

if ((!domTable) || (domTable.className.search('lighttable') === -1)) {     // error: we need a lighttable with ID 'pengData' return; }   // the button row is the header row at the end added by lighttable domButtonCell = domTable.getElementsByTagName('tr'); domButtonCell = domButtonCell[domButtonCell.length - 1].getElementsByTagName('th'); if (domButtonCell.length === 0) { // try again later if (document.addEventListener) {       document.addEventListener('DOMContentLoaded', function onReady        {          document.removeEventListener('DOMContentLoaded', onReady);          main;        }); window.addEventListener('load', main); }     else if (document.attachEvent) {       document.attachEvent('onreadystatechange', function onReady        {          // IE can get overzealous with 'interactive'          if (document.readyState === 'complete')          {            document.detachEvent('onreadystatechange', onReady);            main;          }        }); window.attachEvent('onload', main); }     return; }   isReady = true; domButtonCell = domButtonCell[0];

domButton = document.createElement('input'); domButton.type = 'button'; domButton.value = 'Use selection';

if (document.addEventListener) { // for most browsers, except IE 8 and earlier domButton.addEventListener('click', onClick); }   else if (document.attachEvent) { // for IE 8 and earlier domButton.attachEvent('onclick', onClick); }

domButtonCell.appendChild(domButton, true); }); });