מדיה ויקי:סקריפטים/45.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
//צביעת שם המשתמש בדפי שיחה בצבע אדום
//נוצר על ידי ([[en:User:ais523/highlightmyname2.js]]) שופץ על ידי [[משתמש:חיים 7]]
var w7exception;
try
{
if(wordh===undefined||wordh===null) wordh="";
}
catch(w7exception)
{
wordh="";
}
function highlightmyname(n,p) //node, parent node
{
while(n!==null)
{
if(n.nodeType==3) //text node
{
if(n.data.toLowerCase().indexOf(wordh.toLowerCase())!=-1)
{
var ix=n.data.toLowerCase().indexOf(wordh.toLowerCase());
var t1=ix?document.createTextNode(n.data.substr(0,ix)):null;
var t2=document.createTextNode(n.data.substr(ix,wordh.length));
var t3=ix+wordh.length==n.data.length?null:
document.createTextNode(n.data.substr(ix+wordh.length));
var s1=document.createElement("span");
s1.style.color="#FF0000";
s1.className="word7h";
s1.appendChild(t2);
var s2=document.createElement("span");
if(t1!==null) s2.appendChild(t1);
s2.appendChild(s1);
if(t3!==null) s2.appendChild(t3);
p.replaceChild(s2,n);
if(t3!==null) highlightmyname(t3,s2); //find remaining occurences in the new nodes
n=s2.nextSibling;
}
else
n=n.nextSibling;
}
else
{
if(n.firstChild!==null) highlightmyname(n.firstChild,n);
n=n.nextSibling;
}
}
}
$(function() {
// Don't run on pages that don't have bodyContent
if(document.getElementById('bodyContent') === null) {
return;
}
if(wordh==="") wordh=mw.config.get('wgUserName');
// The two occurrences of 'word7' in the following line are to prevent conflicts with
// other scripts I've written; don't change them to your own username (the script will
// change to your username automatically).
if(location.href.indexOf("?word7")==-1&&location.href.indexOf("&word7")==-1&&
location.href.indexOf("?action=edit")==-1&&location.href.indexOf("?action=submit")==-1&&
location.href.indexOf("&action=edit")==-1&&location.href.indexOf("&action=submit")==-1&&
location.href.indexOf("&action=raw")==-1&&mw.config.get('wgPageName')!="Special:Preferences")
highlightmyname(document.getElementById('bodyContent').firstChild,
document.getElementById('bodyContent'));
});