JS: Difference between revisions
mNo edit summary |
(Right-click h1 to copy name) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<nowiki> | <nowiki> | ||
/* | /* RIGHT-CLICK HEADER TO COPY URL */ | ||
document.querySelectorAll("h2, h3, h4, h5, h6").forEach(function(t) { | |||
t.addEventListener("contextmenu",function(e) { | |||
} | navigator.clipboard.writeText(window.location.href.split("#")[0]+"#"+t.firstElementChild.id) | ||
}) | |||
}); | |||
/* RIGHT-CLICK H1 TO COPY NAME */ | |||
document.querySelectorAll("h1").forEach(function(t) { | |||
t.addEventListener("contextmenu",function(e) { | |||
navigator.clipboard.writeText(window.location.pathname.split('/wiki/')[1]) | |||
}) | |||
}); | |||
/* TOGGLE HIGHLIGHT ON ORDERED LISTS WHEN CLICKED */ | /* TOGGLE HIGHLIGHT ON ORDERED LISTS WHEN CLICKED */ | ||
Line 24: | Line 33: | ||
} else { | } else { | ||
$('body').removeClass("sidebar-collapsed"); | $('body').removeClass("sidebar-collapsed"); | ||
} | } | ||
}); | }); | ||
</nowiki> | </nowiki> |
Latest revision as of 05:08, 25 October 2024
/* RIGHT-CLICK HEADER TO COPY URL */ document.querySelectorAll("h2, h3, h4, h5, h6").forEach(function(t) { t.addEventListener("contextmenu",function(e) { navigator.clipboard.writeText(window.location.href.split("#")[0]+"#"+t.firstElementChild.id) }) }); /* RIGHT-CLICK H1 TO COPY NAME */ document.querySelectorAll("h1").forEach(function(t) { t.addEventListener("contextmenu",function(e) { navigator.clipboard.writeText(window.location.pathname.split('/wiki/')[1]) }) }); /* TOGGLE HIGHLIGHT ON ORDERED LISTS WHEN CLICKED */ $(":not(.references li) ol li").click(function (e) { e.stopPropagation(); if(!($(this).hasClass("highlighted"))) { $(this).addClass("highlighted"); $(this).find("li").addClass("highlighted"); } else { $(this).removeClass("highlighted"); $(this).find("li").removeClass("highlighted"); } }); /* TOGGLE SIDEBAR VIA CONSOLEMODS TEXT */ $("#footer-partnersico:first-child").click(function (e) { e.stopPropagation(); if(!($('body').hasClass("sidebar-collapsed"))) { $('body').addClass("sidebar-collapsed"); } else { $('body').removeClass("sidebar-collapsed"); } });