Add dofus-map suppord and rename file
This commit is contained in:
parent
1f478d7626
commit
40cf6d355a
@ -6,7 +6,7 @@
|
|||||||
// @match https://www.gamosaurus.com/jeux/dofus/*
|
// @match https://www.gamosaurus.com/jeux/dofus/*
|
||||||
// @match https://dofus-map.com/*
|
// @match https://dofus-map.com/*
|
||||||
// @match https://dofus-portals.fr/*
|
// @match https://dofus-portals.fr/*
|
||||||
// @version 1.5
|
// @version 1.2
|
||||||
// @author Mazoyer Alexis
|
// @author Mazoyer Alexis
|
||||||
// @description Permet de rendre cliquable toutes les positions [x,y] indiquées sur le site dofuspourlesnoobs
|
// @description Permet de rendre cliquable toutes les positions [x,y] indiquées sur le site dofuspourlesnoobs
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
@ -16,7 +16,7 @@ const displayPopup = (text, status) => {
|
|||||||
let popupDiv = document.createElement('div')
|
let popupDiv = document.createElement('div')
|
||||||
let popupText = document.createElement('p')
|
let popupText = document.createElement('p')
|
||||||
popupText.setAttribute('style', 'color: white; font-size: 1.3em')
|
popupText.setAttribute('style', 'color: white; font-size: 1.3em')
|
||||||
popupDiv.setAttribute('style', 'display: inline-block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 5px; background-color: #5FE026; border: solid 1px #46A31D; padding: 5px 15px; transition: opacity 1s ease-in-out; transition-delay: 1s')
|
popupDiv.setAttribute('style', 'display: inline-block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 5px; background-color: #5FE026; border: solid 1px #46A31D; padding: 5px 15px; transition: opacity 1s ease-in-out; transition-delay: 1s; z-index: 9999999;')
|
||||||
if (!status || status === 'success') {
|
if (!status || status === 'success') {
|
||||||
popupDiv.style.borderColor = '#46A31D'
|
popupDiv.style.borderColor = '#46A31D'
|
||||||
popupDiv.style.backgroundColor = '#5FE026'
|
popupDiv.style.backgroundColor = '#5FE026'
|
||||||
@ -79,7 +79,7 @@ if (!window.location.href.includes('dofus-map')) {
|
|||||||
allGotos[i].addEventListener('contextmenu', event => {
|
allGotos[i].addEventListener('contextmenu', event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (event.srcElement.getAttribute('data-x') !== null && event.srcElement.getAttribute('data-y') !== null && !isNaN(event.srcElement.getAttribute('data-x').replace('-', '')) && !isNaN(event.srcElement.getAttribute('data-y').replace('-', ''))) {
|
if (event.srcElement.getAttribute('data-x') !== null && event.srcElement.getAttribute('data-y') !== null && !isNaN(event.srcElement.getAttribute('data-x').replace('-', '')) && !isNaN(event.srcElement.getAttribute('data-y').replace('-', ''))) {
|
||||||
copyTextToClipboard('[' + event.srcElement.getAttribute('data-x') + ',' + event.srcElement.getAttribute('data-y') + ']')
|
copyTextToClipboard((parameters.has('noob') ? '/p ' : '') + '[' + event.srcElement.getAttribute('data-x') + ',' + event.srcElement.getAttribute('data-y') + ']')
|
||||||
} else {
|
} else {
|
||||||
displayPopup('Cette coordonnée n\'est pas compatible :(', 'error')
|
displayPopup('Cette coordonnée n\'est pas compatible :(', 'error')
|
||||||
}
|
}
|
||||||
@ -87,7 +87,8 @@ if (!window.location.href.includes('dofus-map')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
})()
|
})()
|
||||||
} else {
|
} else if (window.location.href.includes('hunt')) {
|
||||||
|
console.log('Dofus-Map Hunt detected')
|
||||||
const result = document.getElementById('secondLine')
|
const result = document.getElementById('secondLine')
|
||||||
let observer = new MutationObserver(mutations => {
|
let observer = new MutationObserver(mutations => {
|
||||||
mutations.forEach(mutation => {
|
mutations.forEach(mutation => {
|
||||||
@ -95,7 +96,7 @@ if (!window.location.href.includes('dofus-map')) {
|
|||||||
const position = getPositionArray(result.innerHTML.replace( /(<([^>]+)>)/ig, '').replace(';', ',').replace(/\s/g, ''))
|
const position = getPositionArray(result.innerHTML.replace( /(<([^>]+)>)/ig, '').replace(';', ',').replace(/\s/g, ''))
|
||||||
if(position && position.length === 2) {
|
if(position && position.length === 2) {
|
||||||
if (parameters.has('noob')) {
|
if (parameters.has('noob')) {
|
||||||
copyTextToClipboard('[' + position[0] + ',' + position[1] + ']')
|
copyTextToClipboard('/p [' + position[0] + ',' + position[1] + ']')
|
||||||
} else {
|
} else {
|
||||||
copyTextToClipboard(travelCommand + position[0] + ',' + position[1])
|
copyTextToClipboard(travelCommand + position[0] + ',' + position[1])
|
||||||
}
|
}
|
||||||
@ -107,4 +108,21 @@ if (!window.location.href.includes('dofus-map')) {
|
|||||||
observer.observe(result, {
|
observer.observe(result, {
|
||||||
childList: true
|
childList: true
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
console.log('Dofus-Map detected')
|
||||||
|
const result = document.getElementById('mapCoordinates');
|
||||||
|
const mapElement = document.getElementById('mapContainer')
|
||||||
|
|
||||||
|
mapElement.addEventListener('click', event => {
|
||||||
|
const position = getPositionArray(result.innerHTML)
|
||||||
|
console.log(position)
|
||||||
|
if (position && position.length === 2) {
|
||||||
|
if (parameters.has('noob')) {
|
||||||
|
copyTextToClipboard('/p [' + position[0] + ',' + position[1] + ']')
|
||||||
|
} else {
|
||||||
|
copyTextToClipboard(travelCommand + position[0] + ',' + position[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user