bookmarkletでRequireJS

bookmarklet上でRequireJSを使ってjqueryやらcssやらを読み込む。
----

前回のテンプレをbookmarklet対応しただけです。

```bookmarklet-requirejs.js
javascript: function require_use($) {
    console.log("main code here");
    console.log($);
}
function require_def(reqs) {
    require.config({
        map: {
            '*': {
                'pnotify-css': 'https://raw.github.com/sciactive/pnotify/master/jquery.pnotify.default'
            }
        },
        urlArgs: "nocache=" + new Date().getTime(),
        shim: {
            'jquery.ascensor': ['jquery'],
            'jquery.easing': ['jquery'],
            'jquery.scrollTo': ['jquery'],
            'jquery.tmpl': ['jquery'],
            'jquery.splmenu': ['jquery'],
            'jquery.pnotify': ['jquery'],
            'underscore': {
                exports: "_"
            },
            'backbone': {
                deps: ["underscore", "jquery"],
                exports: 'Backbone'
            }
        },
        baseUrl: '/javascripts',
        paths: {
            'jquery.splmenu': 'libs/plugins/jqsimplemenu',
            'jquery.ascensor': 'libs/plugins/jquery.ascensor',
            'jquery.pnotify': 'https://raw.github.com/sciactive/pnotify/master/jquery.pnotify.min',
            'gapi': "https://apis.google.com/js/client",
            'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min',
            'jquery.tmpl': '//ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min',
            'jquery.easing': '//cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js',
            'underscore': '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min',
            'backbone': '//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min',
            'mdn': '//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js',
            'require-css': 'https://raw.github.com/gist/3102735/018a0d9d6b390956956b0ef7a116daa2bd3b34c5/css'
        }
    });
    require(reqs, require_use);
}(function () {
    var s = document.createElement('script');
    s.setAttribute('src', 'http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.5/require.min.js');
    document.getElementsByTagName("body")[0].appendChild(s);
    setTimeout(require_def, 2000,['jquery','require-css!pnotify-css']);
})()
```

いけてないところなど：

* RequireJS自体の読み込みを、2秒待つ事により読み込めている前提としているところ
* require_xxx系がグローバル汚染しているところ
* 使用モジュールの定義(setTimetout)と実装(require_use)が離れている事

以下bookmarklet版

```bookmarklet.js
javascript:function require_use($){console.log($);}function require_def(reqs){require.config({map:{'*':{'pnotify-css':'https://raw.github.com/sciactive/pnotify/master/jquery.pnotify.default'}},urlArgs:"nocache="+new Date().getTime(),shim:{'jquery.ascensor':['jquery'],'jquery.easing':['jquery'],'jquery.scrollTo':['jquery'],'jquery.tmpl':['jquery'],'jquery.splmenu':['jquery'],'jquery.pnotify':['jquery'],'underscore':{exports:"_"},'backbone':{deps:["underscore","jquery"],exports:'Backbone'}},baseUrl:'/javascripts',paths:{'jquery.splmenu':'libs/plugins/jqsimplemenu','jquery.ascensor':'libs/plugins/jquery.ascensor','jquery.pnotify':'https://raw.github.com/sciactive/pnotify/master/jquery.pnotify.min','gapi':"https://apis.google.com/js/client",'jquery':'//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min','jquery.tmpl':'//ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min','jquery.easing':'//cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js','underscore':'//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min','backbone':'//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min','mdn':'//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js','require-css':'https://raw.github.com/gist/3102735/018a0d9d6b390956956b0ef7a116daa2bd3b34c5/css'}});require(reqs,require_use);}(function (){var s=document.createElement('script');s.setAttribute('src','http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.5/require.min.js');document.getElementsByTagName("body")[0].appendChild(s);setTimeout(require_def,2000,['jquery','require-css!pnotify-css']);})()
```