Kullanıcı:Mert Taşkın/common.js

Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript');
popupQueriedRevertSummary="[[Kullanıcı:$3|$3]] ([[Kullanıcı mesaj:$3|ileti]]) kullanıcı adlı ya da IP adresli kullanıcı tarafından oluşturulmuş $2 tarihli sürüm geri getirildi"
popupQueriedRevertToPreviousSummary="[[Kullanıcı:$3|$3]] ([[Kullanıcı mesaj:$3|ileti]]) kullanıcı adlı ya da IP adresli kullanıcı tarafından oluşturulmuş $2 tarihli sürüm geri getirildi"
popupOnEditSelection=true;
popupAdminLinks=false;
imagePopupsForImages=true;

importScript('Kullanıcı:Srhat/strings-tr.js');
//importScript('Kullanıcı:Brk/extedit.js');
importScript('Kullanıcı:Superyetkin/user.js');
//importScript('Kullanıcı:Vito Genovese/top.js');
//importScript('Kullanıcı:Vito_Genovese/Kullanıcı_sekmeleri.js');
importScript('Kullanıcı:Vito Genovese/libs.js');

//importScript('Kullanıcı:Vito_Genovese/HotCat.js');
importScript('MediaWiki:Gadget-HotCat.js');

importScript('Kullanıcı:Superyetkin/VikiDuyuru.js');

//Şablon yardımcısı
//importScript('Kullanıcı:Vito_Genovese/Şablon_yardımcısı.js');

function ModifySidebar(action, section, name, link) {
    try {
        switch (section) {
          case "languages":
            var target = "p-lang";
            break;
          case "toolbox":
            var target = "p-tb";
            break;
          case "navigation":
            var target = "p-Gezinti";
            break;
          default:
            var target = "p-" + section;
            break;
        }

        if (action == "add") {
            var node = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];

            var aNode = document.createElement('a');
            var liNode = document.createElement('li');

            aNode.appendChild(document.createTextNode(name));
            aNode.setAttribute('href', link);
            liNode.appendChild(aNode);
            liNode.className='plainlinks';
            node.appendChild(liNode);
        }

        if (action == "remove") {
            var list = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];

            var listelements = list.getElementsByTagName('li');

            for (var i = 0; i < listelements.length; i++) {
                if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
                    listelements[i].getElementsByTagName('a')[0].href == link) {

                    list.removeChild(listelements[i]);
                }
            }
        }

    } catch(e) {
      // lets just ignore what's happened
      return;
    }
}

function CustomizeModificationsOfSidebar() {
    ModifySidebar("add", "navigation", "Rastgele şablon", "http://tr.wikipedia.org/wiki/Special:Rastgele/Şablon");
    ModifySidebar("add", "navigation", "Rastgele dosya", "http://tr.wikipedia.org/wiki/Special:Rastgele/Dosya");
    ModifySidebar("remove", "navigation", "Ana sayfa", "http://tr.wikipedia.org/wiki/Ana_Sayfa");
    ModifySidebar("remove", "navigation", "Hakkımızda", "http://tr.wikipedia.org/wiki/Vikipedi:Hakk%C4%B1nda");
    ModifySidebar("remove", "navigation", "İçindekiler", "http://tr.wikipedia.org/wiki/Vikipedi:G%C3%B6zat");
}

function AddSitenoticeAlert() {
    document.getElementById('siteNotice').innerHTML = '<div style="border:none;margin: 0;padding:.1em;top:em;color:#000;background:#F0F8FF"><a href="http://tr.wikipedia.org">abc</a></div>';
}

function sitenotice_callback(doc) {
    var t = (new XMLSerializer()).serializeToString(doc);
    //alert(t);
    var con_obj = doc.getElementsByTagName('rev')[0].childNodes[0];
    //alert(con_obj.nodeValue);
    var con_str = con_obj.nodeValue;
    var p_arr = new Array();
    p_arr = con_str.split("\n");
    var rn = Math.floor(Math.random() * (p_arr.length - 2));
    //jsMsg(rn, 'error');

    if (rn >= 0 && window.location.href.indexOf("title") == -1 && window.location.href.indexOf("Özel:") == -1) {
        document.getElementById('siteNotice').innerHTML = '<div style="border:5px solid #cccccc; margin: 0; padding:.1em; top:em; color:#000; background:yellow">' + p_arr[rn] + '</div>';
    }
}

function Sitenotice2() {
    var req = new Bawolff.mwapi.Request({action:'query', prop: "revisions", rvprop:'content', rvparse:'1', titles: 'Kullanıcı:Superyetkin/VikiDuyuru/içerik'});
    req.send(sitenotice_callback, function (error) {alert("A bad thing happened: " + error);});
}

function Cevir() {
    if (document.getElementById("ca-edit") && (mw.config.get('wgAction') == "submit" || mw.config.get('wgAction') == "edit")) {
        var text = document.editform.wpTextbox1.value;
        text = text.replace(/\[\[Category:/gi, "[[Kategori:");
        document.editform.wpTextbox1.value = text;
        //document.getElementById('wpPreview').click();
    }
}

$(CustomizeModificationsOfSidebar);
//$(AddSitenoticeAlert);
//$(Sitenotice2);
$(Cevir);