Add dofus-map hunter feature
This commit is contained in:
parent
9ac7bde94d
commit
1ad5d25abd
@ -6,13 +6,12 @@
|
|||||||
// @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/*
|
||||||
// @grant none
|
// @version 1.3
|
||||||
// @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==
|
||||||
(() => {
|
const travelCommand = '/travel '
|
||||||
const displayPopup = (text, status) => {
|
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')
|
||||||
@ -34,9 +33,9 @@
|
|||||||
popupDiv.parentNode.removeChild(popupDiv)
|
popupDiv.parentNode.removeChild(popupDiv)
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
const copyTextToClipboard = (text, status) => {
|
const copyTextToClipboard = (text, status) => {
|
||||||
let textArea = document.createElement("textarea");
|
let textArea = document.createElement("textarea");
|
||||||
|
|
||||||
textArea.setAttribute('style', 'position: fixed; top: 0; left: 0; width: 2em; height: 2em; padding: 0; border: none; outline: none; boxShadow: none; background: transparent;')
|
textArea.setAttribute('style', 'position: fixed; top: 0; left: 0; width: 2em; height: 2em; padding: 0; border: none; outline: none; boxShadow: none; background: transparent;')
|
||||||
@ -54,9 +53,15 @@
|
|||||||
else displayPopup(msg, 'error')
|
else displayPopup(msg, 'error')
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
document.body.removeChild(textArea);
|
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
|
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>");
|
document.body.innerHTML = document.body.innerHTML.replace(match, "<goto data-x=\"$2$3\" data-y=\"$4$5\">$1[$2$3,$4$5]</goto>");
|
||||||
|
|
||||||
@ -80,4 +85,21 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
})()
|
})()
|
||||||
|
} 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