Quick navigation buttons for Dead Frontier
// ==UserScript==
// @name DF Quick link
// @namespace http://tampermonkey.net/
// @version 1.5.5
// @description Quick navigation buttons for Dead Frontier
// @author SHUN
// @license SHUN
// @match *://fairview.deadfrontier.com/onlinezombiemmo/*
// @match *://*.deadfrontier.com/onlinezombiemmo/*
// @icon https://i.imgur.com/wDmstST.png
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
console.log('Quick Link English version loaded');
// Wait for page load
let checkCount = 0;
const maxChecks = 20;
function checkPageLoaded() {
checkCount++;
if (document.body && document.body.innerHTML.length > 1000) {
console.log('Page loaded, creating button panel');
createButtonPanel();
return;
}
if (checkCount < maxChecks) {
console.log('Waiting for page load... (' + checkCount + '/' + maxChecks + ')');
setTimeout(checkPageLoaded, 500);
} else {
console.log('Max wait time reached, forcing button creation');
createButtonPanel();
}
}
function createButtonPanel() {
if (document.getElementById('quick-link-container')) {
console.log('Button container already exists');
return;
}
var container = createButtonContainer();
document.body.appendChild(container);
setCustomPosition(container);
window.addEventListener('resize', function() {
setCustomPosition(container);
});
addRainbowAnimation();
console.log('Button panel created');
}
function createButtonContainer() {
var container = document.createElement('div');
container.id = 'quick-link-container';
container.style.position = 'fixed';
container.style.zIndex = '1000';
container.style.backgroundImage = 'url("https://i.imgur.com//icHXrC4.jpeg")';
container.style.backgroundSize = 'cover';
container.style.padding = '4px';
container.style.borderRadius = '30px';
container.style.display = 'flex';
container.style.flexDirection = 'column';
container.style.gap = '3px';
container.style.width = '55px';
container.style.height = 'auto';
var buttons = [
{ name: 'Fast Travel', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=61' },
{ name: 'Guild', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=56' },
{ name: 'Crafting', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=59' },
{ name: 'Gambling', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=49' },
{ name: 'Convenience', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=84' },
{ name: 'Masteries', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=81' },
{ name: 'Profile', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?action=profile' },
{ name: 'Challenges', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=62' },
{ name: 'Market', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=35' },
{ name: 'Bank', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=15' },
{ name: 'Storage', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=50' },
{ name: 'Park', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=24' },
{ name: 'Inner City', link: 'https://fairview.deadfrontier.com/onlinezombiemmo/index.php?page=0' }
];
buttons.forEach(function(buttonInfo) {
createQuickNavigationButton(container, buttonInfo.name, buttonInfo.link);
});
createMoveButton(container);
return container;
}
function createQuickNavigationButton(container, buttonTitle, url) {
let button = document.createElement("button");
button.textContent = buttonTitle;
button.id = buttonTitle;
button.style.height = "max-content";
button.style.padding = "3px";
button.style.margin = "1px";
button.style.border = "1px solid #666";
button.style.borderRadius = "4px";
button.style.background = "#4a4a4a";
button.style.color = "white";
button.style.cursor = "pointer";
button.style.fontSize = "10px";
button.style.fontWeight = "bold";
button.style.width = "100%";
button.addEventListener("click", function() {
window.location.href = url;
});
button.addEventListener('mouseover', function() {
button.style.animation = 'rainbow 3s infinite';
button.style.background = '#666';
});
button.addEventListener('mouseout', function() {
button.style.animation = '';
button.style.background = '#4a4a4a';
});
container.appendChild(button);
}
function createMoveButton(container) {
let moveButton = document.createElement("button");
moveButton.textContent = "Move";
moveButton.style.padding = '6px';
moveButton.style.margin = '2px';
moveButton.style.border = 'none';
moveButton.style.borderRadius = '5px';
moveButton.style.backgroundColor = '#28a745';
moveButton.style.color = 'white';
moveButton.style.cursor = 'pointer';
moveButton.style.fontSize = '9px';
moveButton.style.fontWeight = 'bold';
moveButton.style.width = '100%';
moveButton.addEventListener('mousedown', function(e) {
e.preventDefault();
e.stopPropagation();
var offsetX = e.clientX - container.getBoundingClientRect().left;
var offsetY = e.clientY - container.getBoundingClientRect().top;
function mouseMoveHandler(e) {
container.style.left = (e.clientX - offsetX) + 'px';
container.style.top = (e.clientY - offsetY) + 'px';
container.style.right = 'auto';
}
function mouseUpHandler() {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
savePosition(container);
}
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
});
container.appendChild(moveButton);
}
function setCustomPosition(container) {
var savedLeft = localStorage.getItem('quickLink_left');
var savedTop = localStorage.getItem('quickLink_top');
if (savedLeft && savedTop) {
container.style.left = savedLeft + 'px';
container.style.top = savedTop + 'px';
container.style.right = 'auto';
return;
}
if (window.innerWidth <= 960) {
container.style.left = '10px';
container.style.top = '600px';
container.style.right = 'auto';
} else {
container.style.left = '10px';
container.style.top = '230px';
container.style.right = 'auto';
}
}
function addRainbowAnimation() {
if (document.getElementById('rainbow-style')) return;
var style = document.createElement('style');
style.id = 'rainbow-style';
style.textContent = `
@keyframes rainbow {
0% { background-color: red; }
14% { background-color: orange; }
28% { background-color: yellow; }
42% { background-color: green; }
57% { background-color: blue; }
71% { background-color: indigo; }
85% { background-color: violet; }
100% { background-color: red; }
}
`;
document.head.appendChild(style);
}
function savePosition(container) {
localStorage.setItem('quickLink_left', container.style.left.replace('px', ''));
localStorage.setItem('quickLink_top', container.style.top.replace('px', ''));
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', checkPageLoaded);
} else {
setTimeout(checkPageLoaded, 1000);
}
window.addEventListener('beforeunload', function() {
var container = document.getElementById('quick-link-container');
if (container) {
savePosition(container);
}
});
})();