Skip to content

Instantly share code, notes, and snippets.

@BobuSumisu
Created January 12, 2015 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BobuSumisu/d5a3fccbd4f6ddbc2817 to your computer and use it in GitHub Desktop.
Save BobuSumisu/d5a3fccbd4f6ddbc2817 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Wowhead Items TSM
// @namespace http://github.com/BobuSumisu
// @version 0.1
// @description Easy TSM Import from Wowhead Item Lists
// @author Øyvind Ingvaldsen <oyvind.ingvaldsen@gmail.com>
// @match http://www.wowhead.com/items=*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function getAllIds() {
var ids = [];
for(var id in g_items) {
if(typeof g_items[id] != 'function') {
ids.push(id);
}
}
return ids;
}
function getSelectedIds() {
var ids = [];
$('#lv-items > table > tbody > tr.checked a.listview-cleartext').each(function() {
ids.push($(this).attr('href').substring(6));
});
return ids;
}
function main() {
var $btnSelected = $('<input type="button" value="TSMI Selected">')
.on('click', function() {
$outTxt.text(getSelectedIds());
$outDiv.toggle();
});
var $btnAll = $('<input type="button" value="TSMI All">')
.on('click', function() {
$outTxt.text(getAllIds());
$outDiv.toggle();
});
var $nav = $("#lv-items > div.listview-band-top > div.listview-withselected");
$nav.append($btnSelected);
$nav.append($btnAll);
var $outDiv = $('<div style="display:none; margin: 20px;"></div>');
var $outTxt = $('<textarea style="box-sizing: border-box; height:100px; width:100%;"></textarea>').appendTo($outDiv);
var $closeOut = $('<input type="button" value="Close TSMI" style="float:right; background-color:#a71a19; margin:5px 0;">').appendTo($outDiv)
.on('click', function() {
$outDiv.hide();
});
$outDiv.appendTo('#lv-items > div.listview-band-top');
}
setTimeout(main, 250);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment