All pastes #1587743 Raw Edit

nicovideo_mark.user.js

public javascript v1 · immutable
#1587743 ·published 2009-10-01 13:50 UTC
rendered paste body
// ==UserScript==// @name NicoVideo_mark// @namespace d.hatena.ne.jp/Sore_0// @original d.hatena.ne.jp/shrkw// @description Mark your favorite videos to watch after// @include http://www.nicovideo.jp/*// @include http://ch.nicovideo.jp/video/*// @exclude http://www.nicovideo.jp/thumb*// @update 2008/02/05// @version   0.3.5// @require http://kojim71.googlepages.com/update_checker.user.js// ==/UserScript== (function(){     // location page    var what_pg = "";    if(/http:\/\/.*?\.nicovideo\.jp\/([^\/]*)\/?/.test(location.href))what_pg = RegExp.$1;    if(what_pg == "watch")return;     // class of clickable space    var coc = "";        function main(context) {  var $clickable = [];  var $clickable_search = [];  if(context && what_pg == "ranking"){   for(var i=0;i<context.length;i++){   $clickable.push($x("descendant::a[contains(concat(' ',normalize-space(@class),' '), ' video ')][contains(@href, 'watch')]/../..[not(contains(@class, 'mb16p4'))]/..", context[i])[0]);   $clickable_search.push($x("descendant::div[contains(concat(' ',normalize-space(@class),' '), ' thumb_frm ')]", context[i])[0]);   }  } else {   var context = (context) ? context[0] : document;   $clickable = $x("descendant::a[contains(concat(' ',normalize-space(@class),' '), ' video ')][contains(@href, 'watch')]/../..[not(contains(@class, 'mb16p4'))]/..", context);   $clickable_search = $x("descendant::div[contains(concat(' ',normalize-space(@class),' '), ' thumb_frm ')]", context);  }   switch (what_pg){  case "watch": return;  case "ranking":   coc = "thumb_frm";   $clickable = $clickable_search;break;  case "static":   $clickable = $x("descendant::a[contains(concat(' ',normalize-space(@class),' '), ' video ')]/../../../..", context); break;  case "tag":   coc = "thumb_frm";   $clickable = $clickable_search; break;  case "search":   coc = "thumb_frm";   $clickable = $clickable_search; break;  case "newarrival":   coc = "thumb_frm";   $clickable = $clickable_search; break;  case "recent":   coc = "thumb_frm";   $clickable = $clickable_search; break;  case "myvideo":   coc = "thumb_frm";   $clickable = $clickable_search; break;  case "hotlist":   coc = "thumb_frm";   $clickable = $clickable_search; break;  case "user":   var $clickable = $x("descendant::a[contains(concat(' ',normalize-space(@class),' '), ' video ')][contains(@href, 'watch')]/../..", context); break;  case "mymemory":   $clickable = $clickable.map(parent); break;  case "history":   $clickable = $clickable.map(parent); break;  case "mylist":        var $clickable = $x("id('mylists')//descendant::a[contains(concat(' ',normalize-space(@class),' '), ' video ')][contains(@href, 'watch')]/../..[not(contains(@class, 'mb16p4'))]/..", context); break;  case "my": break;  case "mylist_edit": break;   // channel & community video page  case "video": break;   // toppage  default :   coc = "thumb_frm";   $clickable = $clickable_search; break;  }  $clickable.forEach(click);    }    function parent(elem){return elem.parentNode;}    function click(elem){      var self = elem;      elem.addEventListener("click", function(e){    if(e.target.tagName == "A" || e.target.tagName == "INPUT")return;    if(e.target.tagName == "IMG")e.preventDefault();    toggleClass(self)}, false);    }    function toggleClass(elem){      elem.setAttribute("marker", (elem.getAttribute("marker") == "marked") ? "" : "marked");    }    function $x(xpath, context){  var x = document.evaluate(xpath, context, null, 7, null);  var array = [];  for(var i = 0;i < x.snapshotLength;i++){   array.push(x.snapshotItem(i));  }  return array;    }    function addFilter(filter, i) {  i = i || 4   if (window.AutoPagerize && window.AutoPagerize.addFilter) {    window.AutoPagerize.addFilter(filter);   }   else if (i > 1) {    setTimeout(arguments.callee, 1000, filter, i - 1);   }    }     main();    addFilter(main);         GM_addStyle("div[marker=marked] , tr[marker=marked]{" +    "background:#FFCCCC none repeat scroll 0 0;" +    "}");     new UpdateChecker({  script_name: "NicoVideo_mark"  ,script_url: "http://kojim71.googlepages.com/nicomark.user.js"  ,current_version: "0.3.5"    }); })();