MediaWiki:Gadget-Redirects.js: Difference between revisions
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
mNo edit summary |
m (update deprecated wg variables to mw.config) |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
// adds a tab to the top of pages, when clicked it highlights all links on the page that are redirects. | // adds a tab to the top of pages, when clicked it highlights all links on the page that are redirects. | ||
// -------------------------------------------------------- | // -------------------------------------------------------- | ||
if (wgCanonicalNamespace != 'Special' && | var action = mw.config.get('wgAction'); | ||
!= 'unwatch' && | if (mw.config.get('wgCanonicalNamespace') != 'Special' && action != 'history' && action != 'delete' && action != 'watch' && action | ||
!= 'unwatch' && action != 'protect' && action != 'markpatrolled' && action != 'rollback' && document.URL.indexOf('diff=') <= 0) | |||
{ | { | ||
var highlightRedirects = { | var highlightRedirects = { | ||
Line 29: | Line 30: | ||
with(highlightRedirects) | with(highlightRedirects) | ||
{ | { | ||
addPortletLink ('p-cactions', 'javascript:highlightRedirects.run();', 'Redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r') || | mw.util.addPortletLink ('p-cactions', 'javascript:highlightRedirects.run();', 'Redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r') || | ||
addPortletLink ('views', 'javascript:highlightRedirects.run();', 'Redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r'); | mw.util.addPortletLink ('views', 'javascript:highlightRedirects.run();', 'Redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r'); | ||
} | } | ||
} | } |
Latest revision as of 04:45, March 19, 2017
// -------------------------------------------------------- // redirects // adds a tab to the top of pages, when clicked it highlights all links on the page that are redirects. // -------------------------------------------------------- var action = mw.config.get('wgAction'); if (mw.config.get('wgCanonicalNamespace') != 'Special' && action != 'history' && action != 'delete' && action != 'watch' && action != 'unwatch' && action != 'protect' && action != 'markpatrolled' && action != 'rollback' && document.URL.indexOf('diff=') <= 0) { var highlightRedirects = { tab_redirects : null, addStylesheetRule : function(tag, style) { var ss = document.styleSheets[0]; if (ss.insertRule) { ss.insertRule(tag + '{' + style + '}', ss.cssRules.length); } else if (ss.addRule) { ss.addRule(tag, style); } }, run : function() { highlightRedirects.addStylesheetRule('a.mw-redirect', 'color:red'); highlightRedirects.addStylesheetRule('a.mw-redirect:visited', 'color:hotpink'); }, install : function() { with(highlightRedirects) { mw.util.addPortletLink ('p-cactions', 'javascript:highlightRedirects.run();', 'Redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r') || mw.util.addPortletLink ('views', 'javascript:highlightRedirects.run();', 'Redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r'); } } }; $(highlightRedirects.install); } //