root/fuktommy.com/trunk/niconico/player_to_link.user.js

Revision 98, 2.5 KB (checked in by fuktommy, 20 months ago)

ニコニコ動画便利ツールのコーナー追加。

  • Property svn:keywords set to Id Revision
Line 
1// ==UserScript==
2// @name        Nicovideo Player to Link
3// @namespace   http://fuktommy.com/niconico/
4// @description Nicovideo external player wittern by script element to link.
5// @include     http://mixi.jp/*
6// @include     http://*.fc2.com/*
7// ==/UserScript==
8
9//
10// Copyright (c) 2008 Satoshi Fukutomi <info@fuktommy.com>.
11// All rights reserved.
12//
13// Redistribution and use in source and binary forms, with or without
14// modification, are permitted provided that the following conditions
15// are met:
16// 1. Redistributions of source code must retain the above copyright
17//    notice, this list of conditions and the following disclaimer.
18// 2. Redistributions in binary form must reproduce the above copyright
19//    notice, this list of conditions and the following disclaimer in the
20//    documentation and/or other materials provided with the distribution.
21//
22// THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
23// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
26// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32// SUCH DAMAGE.
33//
34// $Id$
35//
36
37(function() {
38    function playerToLink() {
39        var scripts = document.getElementsByTagName('script');
40        var pattern = new RegExp('http://[a-z0-9]+.nicovideo.jp/thumb_watch/([a-z]{2})([0-9]+)');
41        for (var i=scripts.length-1; i>=0; i--) {
42            if (scripts[i].src.search(pattern) == 0) {
43                var cms = RegExp.$1;
44                var num = RegExp.$2;
45                var anchor = document.createElement('a');
46                scripts[i].parentNode.insertBefore(anchor, scripts[i]);
47                anchor.href = 'http://www.nicovideo.jp/watch/' + cms + num;
48                anchor.appendChild(document.createTextNode(cms + num));
49                var img = new Image();
50                img.src='http://tn-skr.smilevideo.jp/smile?i=' + num;
51                anchor.appendChild(img);
52            }
53        }
54    }
55
56    window.addEventListener('load', playerToLink, false);
57})();
Note: See TracBrowser for help on using the browser.