User:BrandonXLF/NoRedirect.js

/*** No Redirect Link ***/

// Adds a link beside links to redirects that doesn't get redirected

// Documentation at en:w:User:BrandonXLF/NoRedirect

// By en:w:User:BrandonXLF

mw.hook('wikipage.content').add(function(content) {

content.find('.mw-redirect')

.filter(function() {

return this.href.indexOf('redirect=no') == -1 &&

this.href.indexOf('oldid=') == -1 &&

this.href.indexOf('diff=') == -1 &&

(this.href.indexOf('action=') == -1 || this.href.indexOf('action=view') != -1);

})

.after(function() {

return $('')

.attr('href', this.href + (this.href.includes('?') ? '&' : '?') + 'redirect=no')

.attr('title', this.title + ' (no redirect)')

.css('cssText', 'margin-left: 1px; user-select: none;')

.append(

$('')

.attr('alt', 'no redirect')

.attr('src', 'data:image/svg+xml,<%2Fsvg>')

.css('cssText', 'height: 0.6em !important; vertical-align: text-top;')

);

});

});