Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Minecraft Dynmap Center Around Player
  3. // @namespace    LunarControl
  4. // @version      0.3
  5. // @description  Centers the Shirecraft map around player specified..
  6. // @author       LunarControl
  7. // @match        https://*.shirecraft.us/dynmap/*
  8. // ==/UserScript==
  9. const STORAGE_LOCATION = "lunar_username";
  10. function setUsername(key) {
  11.     localStorage.setItem(STORAGE_LOCATION, key);
  12.     console.log(`Added key '${key}' to storage. '${localStorage.getItem(STORAGE_LOCATION)}'`)
  13.     console.log(localStorage.getItem(STORAGE_LOCATION));
  14.   }
  15.  
  16. function getParameterByName(name, url) {
  17.     if (!url) url = window.location.href;
  18.     name = name.replace(/[\[\]]/g, '\\$&');
  19.     var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
  20.         results = regex.exec(url);
  21.     if (!results) return null;
  22.     if (!results[2]) return '';
  23.     return decodeURIComponent(results[2].replace(/\+/g, ' '));
  24. }
  25.  
  26. (function() {
  27.     'use strict';
  28.     var lunars = getParameterByName('lunar');
  29.     var setUsername = getParameterByName('name');
  30.     if(lunars == 'true'){
  31.         localStorage.removeItem(STORAGE_LOCATION);
  32.         console.log("Deleted Player");
  33.         window.location.replace("https://www.shirecraft.us/dynmap/");
  34.     }
  35.     else{
  36.         console.log("Continue [" + lunars + "]");
  37.     }
  38.     console.log("setUsername: " + setUsername);
  39.     if(setUsername == "null"){
  40.         setUsername = localStorage.getItem(STORAGE_LOCATION);
  41.     }
  42.     if((setUsername != 'null') && (setUsername != null)){
  43.         localStorage.setItem(STORAGE_LOCATION, setUsername);
  44.         alert("Username set to: " + setUsername);
  45.         window.location.replace("https://www.shirecraft.us/dynmap/");
  46.     }
  47.     if((localStorage.getItem(STORAGE_LOCATION) != null)){
  48.         console.log("Player Exists: " + localStorage.getItem(STORAGE_LOCATION));
  49.     }
  50.     else{
  51.         var playerID = prompt("Please enter Minecraft IGN");
  52.         localStorage.setItem(STORAGE_LOCATION, playerID)
  53.         if (localStorage.getItem(STORAGE_LOCATION) == null || localStorage.getItem(STORAGE_LOCATION) == "") {
  54.             alert("Player ID not set. Please Reload.");
  55.         } else {
  56.             //localStorage.setItem("playerID", playerID);
  57.             alert("Welcome " + localStorage.getItem(STORAGE_LOCATION));
  58.         }
  59.     }
  60. window.addEventListener('load', function() {
  61.     if (/Maps/i.test (document.body.innerHTML) )
  62. {
  63.     console.log ("Found it!");
  64. }
  65.     else{
  66.     console.log("Loading....");}
  67. }, false);
  68.     var username = localStorage.getItem(STORAGE_LOCATION);
  69.     setInterval(function(){
  70.         if (true)
  71.         {
  72.             var link = $('a').filter(function(index) { return $(this).text() === localStorage.getItem(STORAGE_LOCATION); });
  73.             $(link).click();
  74.         }
  75.     }, 5000);
  76. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement