Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
Dustin Loup (talk | contribs) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | document.addEventListener('DOMContentLoaded', function() { | |
− | ('#free_text').wikiEditor; | + | console.log("Script running..."); |
+ | var links = document.querySelectorAll('a[href*="https://ntldstats.com/tld/"]'); | ||
+ | console.log("Links found: ", links.length); | ||
+ | links.forEach(function(link) { | ||
+ | console.log("Original href: ", link.href); | ||
+ | var url = new URL(link.href); | ||
+ | var paths = url.pathname.split('/'); | ||
+ | var lastSegment = paths[paths.length - 1]; | ||
+ | if (lastSegment.startsWith('.')) { | ||
+ | lastSegment = lastSegment.substring(1); // Remove the leading dot | ||
+ | paths[paths.length - 1] = lastSegment; | ||
+ | url.pathname = paths.join('/'); | ||
+ | link.href = url.toString(); | ||
+ | console.log("Modified href: ", link.href); | ||
+ | } | ||
+ | }); | ||
+ | }); | ||
+ | |||
+ | jQuery.getScript('('#free_text').wikiEditor; |
Revision as of 23:59, 22 April 2024
document.addEventListener('DOMContentLoaded', function() {
console.log("Script running...");
var links = document.querySelectorAll('a[href*="https://ntldstats.com/tld/"]');
console.log("Links found: ", links.length);
links.forEach(function(link) {
console.log("Original href: ", link.href);
var url = new URL(link.href);
var paths = url.pathname.split('/');
var lastSegment = paths[paths.length - 1];
if (lastSegment.startsWith('.')) {
lastSegment = lastSegment.substring(1); // Remove the leading dot
paths[paths.length - 1] = lastSegment;
url.pathname = paths.join('/');
link.href = url.toString();
console.log("Modified href: ", link.href);
}
});
});
jQuery.getScript('('#free_text').wikiEditor;