Last active
September 4, 2024 14:14
-
-
Save RobinDev/519b31f335355338530380c971edaa7f to your computer and use it in GitHub Desktop.
Bookmarklet - GA - Drupal 10 - Menu
This file contains hidden or 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
javascript: (function () { function getIndentationLevel(row) { | |
const indentationDiv = row.querySelectorAll(".js-indentation"); | |
return indentationDiv.length; | |
} | |
function getParentRow(row) { | |
const currentIndentLevel = getIndentationLevel(row); | |
console.log(currentIndentLevel); | |
let previousRow = row.previousElementSibling; | |
while (previousRow) { | |
const previousIndentLevel = getIndentationLevel(previousRow); | |
if (previousIndentLevel < currentIndentLevel) { | |
return previousRow; | |
} | |
previousRow = previousRow.previousElementSibling; | |
} | |
return null; | |
} | |
function injectParents() { | |
const rows = document.querySelectorAll("table#menu-overview tbody tr"); | |
rows.forEach((row) => { | |
const parentRow = getParentRow(row); | |
if (parentRow) { | |
const parentLink = parentRow | |
.querySelector(".tabledrag-cell-content__item") | |
.textContent.trim(); | |
const currentLink = | |
row.querySelector(".tabledrag-cell-content__item span") || | |
row.querySelector(".tabledrag-cell-content__item a"); | |
if (currentLink) | |
currentLink.innerHTML = | |
`${currentLink.innerHTML.trim()}` + | |
(currentLink.querySelectorAll("br").length !== 0 ? "" : "<br>") + | |
` <small style="color:rgb(34, 35, 48)">\\ ${parentLink}</small>`; | |
} | |
}); | |
} | |
function removeDisabledItems() { | |
var elements = document.querySelectorAll("tr.menu-disabled"); | |
elements.forEach(function (element) { | |
element.parentNode.removeChild(element); | |
}); | |
} | |
removeDisabledItems(); | |
injectParents(); | |
})(); |
This file contains hidden or 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
javascript: (function() { | |
var text = ""; | |
document.querySelectorAll(".node-voyage h3").forEach(function(e) { | |
text += e.innerText + "\n"; | |
}); | |
text = text.trim(); | |
var textarea = document.createElement("textarea"); | |
textarea.value = text; | |
document.body.appendChild(textarea); | |
textarea.select(); | |
document.execCommand("copy"); | |
document.body.removeChild(textarea); | |
alert("Le texte a été copié dans le presse-papiers."); | |
})(); |
This file contains hidden or 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
javascript: (function () { | |
var location = window.location; | |
var hostname = location.hostname; | |
if (hostname === "www.grandangle.fr") { | |
var newUrl = location.href.replace( | |
"www.grandangle.fr", | |
"grandangle2023.votre-projet.com" | |
); | |
window.location.href = newUrl; | |
} else if (hostname === "grandangle2023.votre-projet.com") { | |
var newUrl = location.href.replace( | |
"grandangle2023.votre-projet.com", | |
"www.grandangle.fr" | |
); | |
window.location.href = newUrl; | |
} | |
})(); |
This file contains hidden or 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
javascript: (function () { | |
var location = window.location; | |
var hostname = location.hostname; | |
if (hostname === "www.grandangle.fr") { | |
var newUrl = location.href.replace( | |
"www.grandangle.fr", | |
"grandangle-d7.votre-projet.com" | |
); | |
window.location.href = newUrl; | |
} else if (hostname === "grandangle-d7.votre-projet.com") { | |
var newUrl = location.href.replace( | |
"grandangle-d7.votre-projet.com", | |
"www.grandangle.fr" | |
); | |
window.location.href = newUrl; | |
} | |
else if (hostname === "grandangle2023.votre-projet.com") { | |
var newUrl = location.href.replace( | |
"grandangle2023.votre-projet.com", | |
"www.grandangle.fr" | |
); | |
window.location.href = newUrl; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment