コンテンツにスキップ

利用者:Was a bee/logandcounter.js

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

多くの 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.
// This script is made based on [[User:Tietew/log.js]].

 
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('キャッシュをパージ'));
  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('ユーザーログ'));
    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('ページのログ'));
  //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);

  // Access counter
  a = document.createElement('a');
  a.appendChild(document.createTextNode('アクセス数'));
  
    dd = new Date();
    yy = dd.getYear();
    mm = dd.getMonth() + 1;
    if (yy < 2000) { yy += 1900; }
    if (mm < 10) { mm = "0" + mm; }
  
  var grok_project_name = wgServer.substr(7, (wgServer.indexOf('.') - 7 ));
  if (grok_project_name == 'commons' || grok_project_name == 'meta'){grok_project_name = grok_project_name + '.m'};

  a.setAttribute('href', 'http://stats.grok.se/' + grok_project_name + '/' + yy + mm + '/' + 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);
  }
}
$(addlogtab);