Archive for the ‘JS’ tag
Detect 32/64-bit platform using JavaScript (Failed!)
/* Why? */
I wanted to detect the platform which visitors use 32-bit or 64-bit using JavaScript on various browsers, for dynamically changing download URL of the new TortoiseHg 1.0 installers. Unfortunately, I couldn’t achieve that goal, but I’d like to put my result for future reference.
Flickr Fav Set: #1 Create new FavSet
/* Introduction */
This series is a tutorial for greasemonkey script Flickr Fav Set introduced in previous blog entry. In this tutorial, I’d like to explain about the overview of user interface, creating new FavSet and add your favorites to FavSet.

If you didn’t installed the script yet or don’t know about Flickr Fav Set, please see this entry first.
Flickr Fav Set: Manage your Favorites on Flickr
/* How does it work ? */
Using this greasemonkey script, you can manage your favorites with “FavSet” (likes “Set” or “Category”) on Flickr.

In Flickr, the user can put star mark “Favorite” on a photo taken by other peoples. However, it’s difficult to look for favorite one since we have a lot of favorite photos. So I created this.
Extension: Adds ColorPicker to Firebug
Utility functions in JavaScript
/* Tested on Firefox 3 */
function $x(x,c){c=c||document;var d=c.ownerDocument||c;
var r=d.evaluate(x,c,null,4,null);for(var i,n=[];i=r.iterateNext();n.push(i));return n}
function $X(x,c){var e=$x(x,c)[0];e&&(arguments.callee.$=e);return e}
function $n(t,o,c){var e = document.createElement(t);if(o){for(var k in o)
{e[k]=o[k]}}if(c){c.forEach(function(ch){e.appendChild(ch)})}return e}
function $t(t){return document.createTextNode(t)}
function $(id){return document.getElementById(id)}
function $b(o,f){return function(){return f.apply(o,arguments)}}
function $e(t,o){t=t.toString();for(var k in o){t=t.replace(new RegExp('#{'+k+'}','g'),o[k])}return t}
function $h(o,a){if(a.length==0)return false;return a.every(function(p){return o.hasOwnProperty(p)})}
function isO(o){return o.constructor.toString()==Object.toString()}
function isA(a){return a.constructor.toString()==Array.toString()}
function isS(s){return (typeof s)=='string'}
function diffA(a,b){b.forEach(function(i){var p=a.indexOf(i);
if(p!=-1){a=a.slice(0,p).concat(a.slice(p+1))}});return a}
function interA(a,b){return a.filter(function(i){return b.indexOf(i)!=-1})}
function unionA(a,b){(a.length
enjoy JS!
プログラミングにおける数学的正しさ
/* $hという関数を作ってみた */
のがことの発端なのです。
$hはオプジェクトが指定した複数のプロパティを全て持っているかテストするユーティリティ関数で、データのバリデーションに使っています。
これが$hのコード:
function $h(obj, props){
return props.every(function(prop){
return obj.hasOwnProperty(prop);
});
}
見たまんま、とてもシンプルです。
が、もし・・・
[/lang_ja]
Read the rest of this entry »
NicoVideo Global Tag Icon updated & comments
/* NicoVideo Global Tag Icon */
updated. You can install new script from here.

I’d like to comment for my script.
Read the rest of this entry »
Smooth following Ranking list to page scrolling on NicoVideo
/* How does it work ? */
This script applies patch that improves behavior of categories list on page scrolling in NicoVideo’s ranking page.

Recently, NicoVideo development team added new feature. Unfortunately, this feature is not good on Firefox. Well, I found description about this in development team blog: ‘works good in Safari’. So I have try and check on Safari for Windows, and it works very smoothly.
So I decide to create this patch.
Read the rest of this entry »
List of Greasemonkey scripts for NicoVideo
/* Recently… */
I created many Greasemonkey script for NicoVideo. However, you know I’m lazy, I received this comment. And so I’d like to write entry about introduce my Greasemonkey script for NicoVideo.
If you find interesting one, please try it.
Read the rest of this entry »
RTM keyconfig update for Firefox 3
/* RTM keyconfig */
I’ve updated RTM config for Firefox 3 + Greasemonkey 0.8.
There is no change of user confg and feature.
rtm_keyconfig.user.js [userscript.org]
/* Causes */
In previous version (0.1.2), It generates the code from user config, makes function (global scope) object and registers it into event handler of EventManager class. However, This code occurs some errors. So I can’t fix this issue.
EventManager.prototype.bodyKeyPressHandler = new Function("ev", "ignoreCombo", newcode);
Recently, I pinpointed the causes that “new Function(…)” occurs error. Therefore, I decide to insert script tag include generated code from user config into html. Like this:
var script = document.createElement('SCRIPT');
script.innerHTML = 'function gm_rtm_keyconfig(ev, ignoreCombo){n' + newcode + 'n}';
document.getElementById('content').appendChild(script);
eventMgr.bodyKeyPressHandler = function(ev, ignoreCombo){
gm_rtm_keyconfig.call(eventMgr, ev, ignoreCombo);
};
/* Conclusion */
Thank you Ofer.
I can’t fix this issue without your comment.
enjoy RTM!
