Skip to content

Instantly share code, notes, and snippets.

@yutsuku
Last active June 23, 2019 23:45
Show Gist options
  • Save yutsuku/cedec305d4697689d154f1ff0077d118 to your computer and use it in GitHub Desktop.
Save yutsuku/cedec305d4697689d154f1ff0077d118 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name WoW Object exporter
// @namespace net.yutsuku.userjs
// @version 0.1
// @description Very simple object exporter helper to be used with TomTom
// @author moh
// @include https://db.rising-gods.de/?object=*
// @include https://db.rising-gods.de/?quest=*
// @include https://db.rising-gods.de/?npc=*
// @include https://db.excalibur.ws/?object=*
// @include https://wowgaming.altervista.org/aowow/?object=*
// @downloadURL https://gist.github.com/yutsuku/cedec305d4697689d154f1ff0077d118/raw/WoW_Object_exporter.user.js
// @updateURL https://gist.github.com/yutsuku/cedec305d4697689d154f1ff0077d118/raw/WoW_Object_exporter.user.js
// @grant GM_setClipboard
// ==/UserScript==
(function() {
'use strict';
/**
* @param {String} HTML representing any number of sibling elements
* @return {NodeList}
*/
function htmlToElements(html) {
var template = document.createElement('template');
template.innerHTML = html;
return template.content.childNodes;
}
function export_data() {
var t = "";
var name = document.querySelector('#main h1') ? document.querySelector('#main h1').innerText : '';
var zone = g_zones[myMapper.zone];
myMapper.getCoords().forEach(function(pin) {
t += '"' + Number.parseFloat(pin[0]).toFixed(2).split('.').join('') + Number.parseFloat(pin[1]).toFixed(2).split('.').join('') + ':' + name + '",' + "\n";
})
GM_setClipboard(t);
alert(t);
}
function export_macro(event) {
var t = "";
var name = document.querySelector('#main h1') ? document.querySelector('#main h1').innerText : '';
var zone = g_zones[myMapper.zone];
myMapper.getCoords().forEach(function(pin) {
//t += '"' + Number.parseFloat(pin[0]).toFixed(2).split('.').join('') + Number.parseFloat(pin[1]).toFixed(2).split('.').join('') + ':' + name + '",' + "\n";
t += '/way ' + zone + ' ' + pin[0] + ' ' + pin[1] + ' ' + name + "\n";
})
//var copyText = document.querySelector("#wow_exporter_clipboard");
//copyText.value = t;
//copyText.select();
//document.execCommand("copy");
GM_setClipboard(t);
alert(t);
event.preventDefault();
return false;
}
var button = htmlToElements('<a class="button-red"><em><span>Export</span></em></a>');
var clipboard = htmlToElements('<input type="hidden" id="wow_exporter_clipboard">');
var anchor = document.querySelectorAll('#main-contents .text');
button[0].addEventListener('click', export_data, false)
button[0].addEventListener('contextmenu', export_macro, false)
anchor[0].prepend(button[0]);
anchor[0].append(clipboard[0]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment