Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Minecraft Dynmap Center Around Player
- // @namespace LunarControl
- // @version 0.3
- // @description Centers the Shirecraft map around player specified..
- // @author LunarControl
- // @match https://*.shirecraft.us/dynmap/*
- // ==/UserScript==
- const STORAGE_LOCATION = "lunar_username";
- function setUsername(key) {
- localStorage.setItem(STORAGE_LOCATION, key);
- console.log(`Added key '${key}' to storage. '${localStorage.getItem(STORAGE_LOCATION)}'`)
- console.log(localStorage.getItem(STORAGE_LOCATION));
- }
- function getParameterByName(name, url) {
- if (!url) url = window.location.href;
- name = name.replace(/[\[\]]/g, '\\$&');
- var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
- results = regex.exec(url);
- if (!results) return null;
- if (!results[2]) return '';
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
- }
- (function() {
- 'use strict';
- var lunars = getParameterByName('lunar');
- var setUsername = getParameterByName('name');
- if(lunars == 'true'){
- localStorage.removeItem(STORAGE_LOCATION);
- console.log("Deleted Player");
- window.location.replace("https://www.shirecraft.us/dynmap/");
- }
- else{
- console.log("Continue [" + lunars + "]");
- }
- console.log("setUsername: " + setUsername);
- if(setUsername == "null"){
- setUsername = localStorage.getItem(STORAGE_LOCATION);
- }
- if((setUsername != 'null') && (setUsername != null)){
- localStorage.setItem(STORAGE_LOCATION, setUsername);
- alert("Username set to: " + setUsername);
- window.location.replace("https://www.shirecraft.us/dynmap/");
- }
- if((localStorage.getItem(STORAGE_LOCATION) != null)){
- console.log("Player Exists: " + localStorage.getItem(STORAGE_LOCATION));
- }
- else{
- var playerID = prompt("Please enter Minecraft IGN");
- localStorage.setItem(STORAGE_LOCATION, playerID)
- if (localStorage.getItem(STORAGE_LOCATION) == null || localStorage.getItem(STORAGE_LOCATION) == "") {
- alert("Player ID not set. Please Reload.");
- } else {
- //localStorage.setItem("playerID", playerID);
- alert("Welcome " + localStorage.getItem(STORAGE_LOCATION));
- }
- }
- window.addEventListener('load', function() {
- if (/Maps/i.test (document.body.innerHTML) )
- {
- console.log ("Found it!");
- }
- else{
- console.log("Loading....");}
- }, false);
- var username = localStorage.getItem(STORAGE_LOCATION);
- setInterval(function(){
- if (true)
- {
- var link = $('a').filter(function(index) { return $(this).text() === localStorage.getItem(STORAGE_LOCATION); });
- $(link).click();
- }
- }, 5000);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement