コンテンツにスキップ

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

提供: Vikipedia
編集の要約なし
編集の要約なし
57行目: 57行目:
// ==UserScript==
// ==UserScript==
// -*- mode:JScript; Encoding:utf8n -*-
// -*- mode:JScript; Encoding:utf8n -*-
// @name          Wikipedia.citePopup
// @name          Vikipedia.citePopup
// @namespace      http://d.hatena.ne.jp/p-arai/
// @description    Add pop-up on reference to footnote
// @description    Add pop-up on reference to footnote
// @include        http://ja.wikipedia.org/wiki/*
// @include        http://2ch.me/vikipedia/
// @grant          none
// @grant          none
//  
//  
// @author        p-arai, yuuAn
// @author        elti
// @version        2012.11.10
// @version        2016.1.7
// ==/UserScript==
// ==/UserScript==


95行目: 94行目:


})();
})();
var popScript    = '//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-popups.js';
var popStyleSheet = '//en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-navpop.css';
if ( window.localCSS ) { popStyleSheet = 'http://localhost:8080/js/navpop.css'; }
function popups_importScriptURI(url) {
var s = document.createElement('script');
s.setAttribute('src',url);
s.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
return s;
}
function popups_importStylesheetURI(url) {
return document.createStyleSheet ? document.createStyleSheet(url) : popups_appendCSS('@import "' + url + '";');
}
function popups_appendCSS(text) {
var s = document.createElement('style');
s.type = 'text/css';
s.rel = 'stylesheet';
if (s.styleSheet) s.styleSheet.cssText = text //IE
else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
document.getElementsByTagName('head')[0].appendChild(s);
return s;
}
popups_importStylesheetURI(popStyleSheet);
popups_importScriptURI(popScript);
if ( typeof mw !== 'undefined' ) {
mw.loader.using('jquery.jStorage', function() {
var k = 'User:Lupin/popups.js',
t = 'Information: You are importing User:Lupin/popups.js' +
' into your common.js or <skin>.js!\n' +
'This script is unmaintained. Please remove this inclusion and enable the Navigation popups Gadget in the preferences of your account instead.',
x = $.jStorage.get( k );
if ( !x ) {
$.jStorage.set( k, 1 );
alert( t );
} else {
x++;
$.jStorage.set( k, x );
if ( x % 25 === 0 ) {
mw.notify( t );
}
}
});
}

2016年1月7日 (木) 15:34時点における版

/*
 * 拡張型折りたたみ要素(EnhancedCollapsibleElements)
 * 説明書:https://ja.wikipedia.org/wiki/Help:拡張型折りたたみ可能要素
 */
importScript('MediaWiki:EnhancedCollapsibleElements.js');

/**
 * Collapsible tables *********************************************************
 *
 * Description: Allows tables to be collapsed, showing only the header. See
 *              [[Vikipedia:NavFrame]].
 * Maintainers: [[User:SupernovaT]]
 */
 
window.autoCollapse = 2;
window.collapseCaption = "隠す";
window.expandCaption = "表示";
 
window.collapseTable = function ( tableIndex ) {
    var Button = document.getElementById( 'collapseButton' + tableIndex );
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
    var i;
 
    if ( Button.firstChild.data === collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = 'none';
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
};
 
window.createCollapseButtons = function() {
    var tableIndex = 0;
    var NavigationBoxes = {};
    var Tables = document.getElementsByTagName( 'table' );
    var i;
 
    function handleButtonLink( index, e ) {
        window.collapseTable( index );
        e.preventDefault();
    }
 
    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {

// ==UserScript==
// -*- mode:JScript; Encoding:utf8n -*-
// @name           Vikipedia.citePopup
// @description    Add pop-up on reference to footnote
// @include        http://2ch.me/vikipedia/
// @grant          none
// 
// @author         elti
// @version        2016.1.7
// ==/UserScript==

(function () {

  // retrive array of cites
  var cites = new Array();
  var lis = document.getElementsByTagName("li");
  for (var i=0; i < lis.length; i++){
    var li = lis[i];
    if (li.id.match(/^cite_note(?:-[\w\.]+){0,}-(\d+)$/)){
      var index = RegExp.$1;
      cites[index] = li;
    }
  }

  // retrive and modify reference element
  var hrefs = document.getElementsByTagName("a");
  for (var i=0; i < hrefs.length; i++){
    var a = hrefs[i];
    if (a.href.match(/#cite_note(?:-[\w\.]+){0,}-(\d+)$/)){
      var index = RegExp.$1;
      if (typeof a.textContent != "undefined") {
        a.title = cites[index].textContent.replace(/^[^]\s*/, "");
      } else {
        a.title = cites[index].innerText.replace(/^[^]\s*/, "");
      }
    }
  }

})();
Cookieは私達のサービスを提供するのに役立ちます。このサービスを使用することにより、お客様はCookieの使用に同意するものとします。