משתמש:פיבר/common.js
מראה
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
/* importUserScript(33);
importUserScript(109);
importUserScript(67);
importUserScript(66); */
// Copied from https://en.wikipedia.org/wiki/User:Enterprisey/watchlist-notice
mw.loader.using( 'mediawiki.util', function () {
var showNotice = function () {
// Stick a "Watchlist update!" notice after the notification count
$( "#pt-notifications-notice" ).after(
$( "<li>" ).append( $( "<a>" )
.text( "★" )
.css( {
"background-color": "green",
"color": "white",
"border-radius": "2px",
"padding": "0.25em 0.45em 0.2em",
"cursor": "pointer",
"font-weight": "bold",
"transition": "background-color 0.5s",
"text-decoration": "none"
} )
.attr( "href", "/wiki/Special:Watchlist" )
.mouseover( updateNotice )
)
.attr( "id", "watchlist-update-notice" )
);
};
var updateNotice = function() {
// Lighten the background color so the user knows we're updating
$( "#watchlist-update-notice a" ).css( "background-color", "#7bff7b" );
// Update the notice
$.getJSON(
mw.util.wikiScript( 'api' ),
{
format: "json",
action: "query",
list: "watchlist",
wlshow: "unread",
wllimit: 1 // Because we're checking if there are *any* entries
} ).done(function( data ) {
if( !data.query ) return;
if( data.query.watchlist.length ) {
// There are new watchlist diffs to read, so show notice
if( !$( "#watchlist-update-notice" ).length ) {
// That is, if it isn't shown already
showNotice();
} else {
// There's already a notice, so change background
$( "#watchlist-update-notice a" ).css( "background-color", "green" );
}
} else {
// No new watchlist diffs to read, so hide notice
$( "#watchlist-update-notice" ).remove();
}
}
);
};
$( document ).ready( function () {
//showNotice();
updateNotice();
window.setInterval( updateNotice, 120000 );
} );
} );