2022-09-02 14:57:31 +00:00
|
|
|
module.exports = function () {
|
|
|
|
mw.hook( 'wikipage.watchlistChange' ).add(
|
|
|
|
function ( /** @type {boolean} */ isWatched, /** @type {string} */ expiry ) {
|
2023-05-02 19:03:13 +00:00
|
|
|
const watchIcon = document.querySelectorAll( '#ca-watch .mw-ui-icon, #ca-unwatch .mw-ui-icon' )[ 0 ];
|
|
|
|
if ( !watchIcon ) {
|
2022-09-02 14:57:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-05-02 19:03:13 +00:00
|
|
|
|
|
|
|
watchIcon.classList.remove(
|
2022-11-14 21:35:57 +00:00
|
|
|
// Vector attaches two icon classes to the element.
|
|
|
|
// Remove the mw-ui-icon one rather than managing both.
|
|
|
|
'mw-ui-icon-star',
|
|
|
|
'mw-ui-icon-unStar',
|
2022-09-02 14:57:31 +00:00
|
|
|
'mw-ui-icon-wikimedia-unStar',
|
|
|
|
'mw-ui-icon-wikimedia-star',
|
|
|
|
'mw-ui-icon-wikimedia-halfStar'
|
|
|
|
);
|
2023-05-02 19:03:13 +00:00
|
|
|
|
2022-09-02 14:57:31 +00:00
|
|
|
if ( isWatched ) {
|
|
|
|
if ( expiry === 'infinity' ) {
|
2023-05-02 19:03:13 +00:00
|
|
|
watchIcon.classList.add( 'mw-ui-icon-wikimedia-unStar' );
|
2022-09-02 14:57:31 +00:00
|
|
|
} else {
|
2023-05-02 19:03:13 +00:00
|
|
|
watchIcon.classList.add( 'mw-ui-icon-wikimedia-halfStar' );
|
2022-09-02 14:57:31 +00:00
|
|
|
}
|
|
|
|
} else {
|
2023-05-02 19:03:13 +00:00
|
|
|
watchIcon.classList.add( 'mw-ui-icon-wikimedia-star' );
|
2022-09-02 14:57:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|