Last active
November 22, 2018 17:06
-
-
Save x-magic/6c2d36d88b0f6fcc54b0615ab3700e53 to your computer and use it in GitHub Desktop.
Various hacks for Zelda Dungeon BotW map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Zelda Dungeon Breath of the Wild Interactive Map Tweaks | |
// @namespace http://www.zeldadungeon.net | |
// @version 0.1.1 | |
// @description Various hacks for Zelda Dungeon BotW map. I'm just too lazy to write a full description. | |
// @include http*://www.zeldadungeon.net/breath-of-the-wild-interactive-map/* | |
// @run-at document-end | |
// @copyright Nope, this contains original code from the website. It's whether piracy or public domain. Sorry Zelda Dungeon. I love you guys! | |
// @updateURL https://gist.githubusercontent.com/x-magic/6c2d36d88b0f6fcc54b0615ab3700e53/raw/ZeldaDungeonBreathoftheWildInteractiveMapTweaks.user.js | |
// @downloadURL https://gist.githubusercontent.com/x-magic/6c2d36d88b0f6fcc54b0615ab3700e53/raw/ZeldaDungeonBreathoftheWildInteractiveMapTweaks.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
//Change how it looks | |
function addGlobalStyle(css) { | |
var head, style; | |
head = document.getElementsByTagName('head')[0]; | |
if (!head) { return; } | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
head.appendChild(style); | |
} | |
function initialiseMyOptions(preloadedTypes){ | |
//Start with categories I wanted | |
var allTypes = ['tower','shrine','lab','mainquest','shrinequest','sidequest','memory','objective','stable','village','inn','store','armor','dye','jewelry','settlement','fountain','statue','completed','hinox','lynel','molduga','talus','seed']; | |
if (typeof testvar === 'undefined') allTypes = preloadedTypes; | |
//Initialise type display | |
$('.legend .selectable').removeClass('selected'); | |
$('.legend .selectable').each(function(){ | |
var currentType = $(this).data('type'); | |
if (jQuery.inArray(currentType, allTypes) > -1) { | |
$(this).addClass('selected'); | |
} | |
}); | |
//Update type register | |
$('.legend .selectable').each(function() { | |
var isSelected = $(this).hasClass('selected'); | |
var type = $(this).data('type'); | |
if (type !== 'all' && type !== 'none' && type !== 'completed') { | |
types[type].show = isSelected; | |
if (type === 'shrine') { | |
// include shrine of resurrection too | |
types.shrine_resurrection.show = isSelected; | |
} | |
} | |
}); | |
updateData(); | |
return false; | |
} | |
$(document).on('click', '.thumbinner', function(){ | |
return false; | |
}); | |
addGlobalStyle('.legend .selected { background: rgba(255,255,255,0.2) !important; }'); | |
setTimeout(function(){ | |
$('a.control').attr('href', '#').removeAttr('target').text('Only show what I wanted').click(initialiseMyOptions); | |
}, 3000); | |
setTimeout(function(){ | |
//To disable info load, this is a GIANT hack! | |
google.maps.event.clearListeners(map, 'click'); | |
google.maps.event.clearListeners(map.data, 'click'); | |
var infoWindow = new google.maps.InfoWindow({maxWidth: 300}); | |
map.addListener('click', function (event) { | |
infoWindow.close(); | |
}); | |
map.data.addListener('click', function (event) { | |
if (event.feature.getGeometry().getType() != 'Point') { | |
return; | |
} | |
// gather data | |
var src = event.feature.getProperty('src').replace('?', '%3F'), | |
name = event.feature.getProperty('name'), | |
link = event.feature.getProperty('link').replace('?', '%3F'), | |
linkParts = link ? link.split('#') : [], // 0 = page, 1 = id/anchor | |
id = event.feature.getProperty('id') || linkParts[1], | |
latLng = event.feature.getGeometry().get(), | |
lat = Math.round(latLng.lat() * 10000) / 10000, | |
lng = Math.round(latLng.lng() * 10000) / 10000, | |
globalId = id || (lat + 'x' + lng); // not actually global, if things share the same coords | |
// open with known content | |
var title = '<h3>' + (link ? '<a target="_blank" href="/wiki/' + link + '">' + name + '</a>' : name) + '</h3>'; | |
function controls() { | |
var toggleFunc = 'toggleCompletion(this, \'' + globalId.replace(/'/g, '\\\'') + '\')'; | |
var editLink = src; | |
if (!editLink || editLink == 'section' || editLink == 'summary') { | |
editLink = linkParts[0]; | |
} | |
return '<div class="iw-controls' + | |
(isCompleted(globalId) ? ' completed' : '') + | |
(editLink ? '' : ' noedit') + '">' + | |
'<a class="complete" onclick="' + toggleFunc + '">' + | |
'<i class="fa fa-check" title="Hide (if "Hide Completed" is selected in the Legend)"></i></a>' + | |
'<a class="uncomplete" onclick="' + toggleFunc + '">' + | |
'<i class="fa fa-undo" title="Show"></i></a>' + | |
'<a class="edit" target="_blank" href="/wiki/index.php?action=edit&title=' + editLink + '">' + | |
'<i class="fa fa-edit"></i></a>' + | |
'<a class="permalink" href="/breath-of-the-wild-interactive-map/?' + (id ? 'id=' + id : 'lat=' + lat + '&lng=' + lng) + '">' + | |
'<i class="fa fa-link"></i></a>' + | |
'</div>'; | |
} | |
infoWindow.close(); | |
infoWindow.setContent(title + controls()); | |
infoWindow.setPosition(latLng); | |
infoWindow.open(map); | |
}); | |
}, 4000); | |
setTimeout(function(){ | |
//Let's load nothing in the beginning | |
initialiseMyOptions([]); | |
}, 5000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've noticed you can no longer navigate to lat lng positions (as in https://www.zeldadungeon.net/breath-of-the-wild-interactive-map/?lat=1.0915&lng=1.0898) or drop pins on the interactive map to discover lat lng. Has this been your experience?