「MediaWiki:Common.js」の版間の差分

Opadmin (トーク | 投稿記録)
Opadmin (トーク | 投稿記録)
 
(同じ利用者による、間の1版が非表示)
行1,246: 行1,246:
 
/* mw に依存する部分の終わり */
 
/* mw に依存する部分の終わり */
 
}());
 
}());
 
/*
 
*  Reference Pop Up
 
*
 
*      This script is under public domain, and comes with ABSOLUTELY NO WARRANTY.
 
*      You can use/modify/redistribute without any permission.
 
*/
 
 
//  for WIkipedia user script
 
//
 
//  How to use:
 
//  * write "importScript('User:Mizusumashi/Script/ReferencePopUp.js');"
 
//    in "User:_ACOUNT_/monobook.js"("_ACOUNT_" is your WIki acount).
 
//  * This script need addOnloadHook()
 
//    in http://upload.wikimedia.org/skins/common/wikibits.js.
 
 
// for Firefox extension "Greasemonkey"
 
//
 
// ==UserScript==
 
// @name          WikipediaReferencePopUp
 
// @namespace      mizusumashi
 
// @include        http://*.wikipedia.org/*
 
// ==/UserScript==
 
 
hrefregex= new RegExp('');
 
hrefregex.compile('http://([^#]+)#(.+)');
 
refregex1 = new RegExp('');
 
refregex1.compile('^(<span [^>]+>)?(<b><a [^>]+>\\^</a></b>|\\^( <a [^>]+><sup><i><b>[^<]+</b></i></sup></a>)+) ', 'i');
 
refregex2 = new RegExp('');
 
refregex2.compile('<[^>]+>', 'g');
 
refregex3 = new RegExp('');
 
refregex3.compile('<span [^>]+>(<a [^>]+><b>.+</b></a></span>&nbsp;)+', 'i');
 
templateregex = new RegExp('');
 
templateregex.compile('^<a [^>]+><b>.+</b></a>$', 'i');
 
 
function isTemplate(foot)
 
{
 
    var ret = templateregex.test(foot.innerHTML);
 
    return ret;
 
}
 
 
function referencePopUp()
 
{
 
    if(navigator.appName == "Microsoft Internet Explorer"){
 
        return;
 
    }
 
 
    var arrayOfReference = document.getElementsByClassName('reference');
 
 
    for( var i = 0; i < arrayOfReference.length; i++){
 
        arrayOfReference[i].firstChild.href.match(hrefregex);
 
 
        var foot = document.getElementById(RegExp.$2);
 
        if(foot){
 
            if(! isTemplate(foot)){
 
                text = foot.innerHTML;
 
                text = text.replace(refregex1, '');
 
                text = text.replace(refregex2, '');
 
            } else { // [[Template:Note label]]
 
                text = foot.parentNode.innerHTML;
 
                text = text.replace(refregex3, '');
 
                text = text.replace(refregex2, '');
 
            }
 
        } else {
 
            text = 'ERROR: There is no footnote.';
 
        }
 
 
        arrayOfReference[i].firstChild.title = text;
 
    }
 
}
 
 
addOnloadHook(referencePopUp); // in Wikipedia user script
 
// referencePopUp(); // in Firefox extension "Greasemonkey"
 
  
 
// </source>
 
// </source>

2015年6月23日 (火) 12:20時点における最新版

最終更新: 10年前
キャンセル

このページの改善に協力

キャンセル

このページのすべての変更を追跡しましょう。