מדיה ויקי:Gadget-Warnings.js
מראה
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
//<source lang="javascript">
/* סקריפט להוספת רשימת אזהרות כשעורכים דף שיחה של אנונימי, נכתב על-ידי ערן */
var warnings = ["בחרו אזהרה כדי להוסיף", "אזהרה", "הבל", "הזמנה", "ניסויים", "תודה", "ויקיזציה", "לך", "תלונה", "טעות", "נייטרליות", "נחסמת", "מילון", "כבר קיים", "שגיאה", "העתקה", "פרסומת", "נמחק", "הסבר", "בוטל", "סגנון"];
function warningsList() {
if( !document.getElementById("edit-templates") ) return; // not edit page
if( wgNamespaceNumber != 3 || !/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test( wgTitle ) ) return; // not an anonymous user talk
var select = document.createElement("select");
select.id = "warningsList";
select.onchange = function() {
insertWarning( this.selectedIndex, this[this.selectedIndex].title );
this.selectedIndex = 0;
return false;
}
for( var i = 0; i < warnings.length; i++ ) {
select = createOptionElement( select, warnings[i] );
}
addEditSelect( "אזהרות", select );
}
function insertWarning( index, title ) {
if( index > 0 ) {
document.getElementById("wpSummary").value += title;
document.getElementById("wpTextbox1").value += "{" + "{ס:" + title + "}} ~~" + "~~";
}
}
addOnloadHook(warningsList);
//</source>