),
// uses 'watch' or 'unwatch' message
'text' => $this->msg( $mode )->text(),
- 'href' => $title->getLocalURL( [ 'action' => $mode ] )
+ 'href' => $title->getLocalURL( [ 'action' => $mode ] ),
+ // Set a data-mw=interface attribute, which the mediawiki.page.ajax
+ // module will look for to make sure it's a trusted link
+ 'data' => [
+ 'mw' => 'interface',
+ ],
];
}
}
);
$( function () {
- var $links = $( '.mw-watchlink a, a.mw-watchlink' );
- // Restrict to core interfaces, ignore user-generated content
- $links = $links.filter( ':not( #bodyContent *, #content * )' );
+ var $links = $( '.mw-watchlink a[data-mw="interface"], a.mw-watchlink[data-mw="interface"]' );
+ if ( !$links.length ) {
+ // Fallback to the class-based exclusion method for backwards-compatibility
+ $links = $( '.mw-watchlink a, a.mw-watchlink' );
+ // Restrict to core interfaces, ignore user-generated content
+ $links = $links.filter( ':not( #bodyContent *, #content * )' );
+ }
$links.click( function ( e ) {
var mwTitle, action, api, $link;