Add dofus-map hunter feature
This commit is contained in:
parent
9ac7bde94d
commit
1ad5d25abd
@ -6,12 +6,11 @@
|
||||
// @match https://www.gamosaurus.com/jeux/dofus/*
|
||||
// @match https://dofus-map.com/*
|
||||
// @match https://dofus-portals.fr/*
|
||||
// @grant none
|
||||
// @version 1.2
|
||||
// @version 1.3
|
||||
// @author Mazoyer Alexis
|
||||
// @description Permet de rendre cliquable toutes les positions [x,y] indiquées sur le site dofuspourlesnoobs
|
||||
// ==/UserScript==
|
||||
(() => {
|
||||
const travelCommand = '/travel '
|
||||
const displayPopup = (text, status) => {
|
||||
let popupDiv = document.createElement('div')
|
||||
let popupText = document.createElement('p')
|
||||
@ -56,7 +55,13 @@
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
|
||||
const travelCommand = '/travel '
|
||||
const getPositionArray = chaine => {
|
||||
const rule = /[-]{0,1}[0-9]{1,2}/g
|
||||
return chaine.match(rule)
|
||||
}
|
||||
|
||||
if (!window.location.href.includes('dofus-map')) {
|
||||
(() => {
|
||||
const match = /[\[]{0,1}(\s)*(-){0,1}([0-9]+)[\s]*,[\s]*(-){0,1}([0-9]+)[\s]*[\]]{0,1}/g
|
||||
document.body.innerHTML = document.body.innerHTML.replace(match, "<goto data-x=\"$2$3\" data-y=\"$4$5\">$1[$2$3,$4$5]</goto>");
|
||||
|
||||
@ -81,3 +86,20 @@
|
||||
}
|
||||
|
||||
})()
|
||||
} else {
|
||||
const result = document.getElementById('secondLine')
|
||||
let observer = new MutationObserver(mutations => {
|
||||
mutations.forEach(mutation => {
|
||||
if (mutation.addedNodes.length) {
|
||||
const position = getPositionArray(result.innerHTML.replace( /(<([^>]+)>)/ig, '').replace(';', ',').replace(/\s/g, ''))
|
||||
if(position && position.length === 2) {
|
||||
copyTextToClipboard(travelCommand + position[0] + ',' + position[1])
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
observer.observe(result, {
|
||||
childList: true
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user