uso reader

  • /*
     * @title uso reader
     * @description replace Userscripts.org to readonly-mirror
     * @include http://*
     * @include https://*
     * @license MIT http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // e.g. show my uso
    // http://noromanba.flavors.me
    // https://userscripts.org/users/436459/scripts
    // http://userscripts.org:8080/users/436459/scripts
    
    // c.f. smilar script
    // https://greasyfork.org/scripts/2222-uso-mirror/code
    
    // for readonly use; script install are unsafe
    (function () {
        var HOST = [
            'userscripts-mirror.org',
            'www.webextender.net'
        ].shift();
    
        // c.f. debouncing w/ queue
        //      https://gist.github.com/noromanba/2669793
        //      http://javascript.g.hatena.ne.jp/edvakf/20100204/1265312155
        var forEach = Array.prototype.forEach,
            timer, queue = [];
            ELEMENT_NODE = document.ELEMENT_NODE, DOCUMENT_NODE = document.DOCUMENT_NODE;
        var toMirror = function (context) {
            queue.push(context);
            clearTimeout(timer);
    
            timer = setTimeout(function () {
                forEach.call(queue, function (node) {
                    if (node.nodeType !== ELEMENT_NODE && node.nodeType !== DOCUMENT_NODE) return;
                    // TBD avoid cache sites; e.g. wayback, archive.today et al.
                    forEach.call(node.querySelectorAll('a[href*="://userscripts.org"]'), function (link) {
                        link.protocol = 'http';
                        link.hostname = HOST;
                        link.port = 80;  // readonly mode when uso killing; "http://userscript.org:8080/..."
                    });
                });
            queue = [];
            }, 10);
        };
        toMirror(document);
    
        // TBD MutationObserver or click binding
        document.body.addEventListener('DOMNodeInserted', function (evt) {
            toMirror(evt.target);
        });
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2014/11/04 07:15:15 - 2014-11-04
  2. 2014/10/19 01:29:15 - 2014-10-19
  3. 2014/10/19 01:23:31 - 2014-10-19
  4. 2014/10/19 01:19:41 - 2014-10-19
  5. 2014/10/19 01:17:26 - 2014-10-19
  6. 2014/10/18 23:36:18 - 2014-10-18
  7. 2014/10/17 06:08:47 - 2014-10-17
  8. 2014/10/17 05:55:16 - 2014-10-17
  9. 2014/10/17 05:51:31 - 2014-10-17