-
-
Save bchagas-puc-rio/4fdecfede11868714293f5f654ad2e54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name meu_novo_botao | |
// @namespace http://www.eud.net.br/gmscripts | |
// @description Meu novo botão na tela de dashboard | |
// @include http://agroup.eud.net.br/main | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
console.log('Meu novo botão'); | |
console.log('Iniciando'); | |
var inserido = false; | |
function lookForElement(xpath) { | |
var snapResults = document.evaluate(xpath, | |
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
if (snapResults.snapshotLength > 0) return snapResults.snapshotItem(0); //return the first element | |
else return false; | |
} | |
// document.addEventListener('DOMSubtreeModified', function (ev) { | |
// console.log('DOMSubtreeModified'); | |
document.addEventListener('DOMNodeInserted', function (ev) { | |
console.log('DOMNodeInserted'); | |
if (!inserido) { | |
var elem = lookForElement('/html/body/ng-view/div/div/div[2]/div/div[2]'); | |
if (!!elem) { | |
var newBtn = document.createElement('a'); | |
newBtn.classList.add('btn'); | |
newBtn.classList.add('btn-default'); | |
newBtn.setAttribute('href', '/events/new'); | |
newBtn.innerHTML = '+ New group'; | |
inserido = true; | |
elem.appendChild(newBtn); | |
} | |
// console.log(ev); | |
// if (/event/.test(ev.target) && /div.panel-body/.test(ev.relatedNode)) { | |
// console.log('achou com relatedNode!'); | |
// } | |
// if (/div.panel-body/.test(ev.target)) { | |
// console.log('achou com target!'); | |
// } | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment