コンテンツにスキップ

利用者:Tietew/log.js

これはこのページの過去の版です。Tietew (会話 | 投稿記録) による 2006年6月7日 (水) 11:37個人設定で未設定ならUTC)時点の版 (whois)であり、現在の版とは大きく異なる場合があります。

お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。

多くの WindowsLinux のブラウザ

  • Ctrl を押しながら F5 を押す。

Mac における Safari

  • Shift を押しながら、更新ボタン をクリックする。

Mac における ChromeFirefox

  • Cmd Shift を押しながら R を押す。

詳細についてはWikipedia:キャッシュを消すをご覧ください。

// This script is under public domain, and comes with ABSOLUTELY NO WARRANTY.
// You can use/modify/redistribute without any permission.

function addlogtab()
{
  // get title from URL
  var u = location.href;
  if(/[\?&]title=([^&]+)/.test(u)) u = RegExp.$1;
  else if(/\/wiki\/([^\?]+)/.test(u)) u = RegExp.$1;
  else return;
  
  // insertion point of toolbox
  var lit = document.getElementById('t-recentchangeslinked');
  if(!lit) lit = document.getElementById('t-whatlinkshere');
  // if not found, we're in special page
  if(!lit) return;
  
  // insertion point of actions tab
  var act = document.getElementById('p-cactions');
  act = act.getElementsByTagName('ul')[0];
  
  // get namespace number
  var ns = document.body.className.split(' ');
  for(var i = 0; i < ns.length; ++i) {
    var r = /^ns-([0-9]+)$/.exec(ns[i]);
    if(r) { ns = parseInt(r[1]); break; }
  }
  if(typeof ns != 'number') return;
  
  // purge cache
  a = document.createElement('a');
  a.appendChild(document.createTextNode('Purge cache'));
  a.setAttribute('href', '/wiki/' + u + '?action=purge');
  a.setAttribute('title', decodeURI(u));
  li = document.createElement('li');
  li.appendChild(a);
  lit.parentNode.insertBefore(li, lit.nextSibling);
  
  // User: or User_talk:
  if(ns == 2 || ns == 3) {
    // strip subpage
    var user = decodeURI(u).replace(/^[^:]+:/, '').replace(/\/.*/, '');
    // User's log
    a = document.createElement('a');
    a.appendChild(document.createTextNode('User log'));
    a.setAttribute('href', '/wiki/Special:Log?user=' + encodeURI(user));
    a.setAttribute('title', 'User:' + user + "'s log");
    li = document.createElement('li');
    li.appendChild(a);
    lit.parentNode.insertBefore(li, lit.nextSibling);
    // IP address
    var m = /^\d+\.\d+\.\d+\.\d+$/.exec(user);
    if(m) {
      a = document.createElement('a');
      a.appendChild(document.createTextNode('whois'));
      a.setAttribute('href', 'http://linky.wikipedia.jp/whois?key=' + encodeURI(user));
      a.setAttribute('title', 'whois query for ' + user);
      li = document.createElement('li');
      li.appendChild(a);
      act.appendChild(li);
    }
  }
  
  // Page log
  a = document.createElement('a');
  a.appendChild(document.createTextNode('Page log'));
  a.setAttribute('href', '/wiki/Special:Log?page=' + u);
  a.setAttribute('title', decodeURI(u));
  li = document.createElement('li');
  li.appendChild(a);
  lit.parentNode.insertBefore(li, lit.nextSibling);
  
  // Image: or Image_talk:
  if((ns == 6 || ns == 7) && location.host != 'commons.wikimedia.org') {
    var img = u.replace(/^[^:]+:/, (ns == 6 ? 'Image:' : 'Image_talk:'));
    // link to commons
    a = document.createElement('a');
    a.appendChild(document.createTextNode('commons'));
    a.setAttribute('href', 'http://commons.wikimedia.org/wiki/' + img);
    a.setAttribute('title', 'commons:' + decodeURI(img));
    li = document.createElement('li');
    li.appendChild(a);
    act.appendChild(li);
  }
}
addOnloadHook(addlogtab);