List Linked Images

  • /*
    @title     List Linked Images
    @include   http://*
    @include   https://*
    @license   MIT License
    */
    var add, add_linked_image, filter, process, sources;
    
    sources = [];
    
    filter = null;
    
    process = function() {
      var images, src;
      sources = sources.reverse().reduceRight(function(a, b) {
        if (b && a.indexOf(b) === -1) {
          return a.concat(b);
        } else {
          return a;
        }
      }, []);
      images = (function() {
        var _i, _len, _results;
        _results = [];
        for (_i = 0, _len = sources.length; _i < _len; _i++) {
          src = sources[_i];
          _results.push("" + src + "\n<img src=\"" + src + "\">\n");
        }
        return _results;
      })();
      if (images.length) {
        return document.body.outerHTML = "<body>" + (images.join('')) + "</body>";
      } else {
        return alert("Image Not Found");
      }
    };
    
    add_linked_image = function() {
      var a;
      return add((function() {
        var _i, _len, _ref, _results;
        _ref = document.links;
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          a = _ref[_i];
          _results.push(a.href);
        }
        return _results;
      })());
    };
    
    add = function(target) {
      var items;
      items = Array.prototype.slice.call(target).filter(function(item) {
        return /.+\.(?:jpe?g|gif|png|svg|bmp)$/.test(item);
      });
      return sources = sources.concat(filter ? items.map(filter) : items);
    };
    
    add_linked_image();
    
    process();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2012/02/28 03:50:15 - 2012-02-28
  2. 2012/02/28 01:58:06 - 2012-02-28
  3. 2012/02/28 01:51:37 - 2012-02-28
  4. 2012/02/28 01:45:58 - 2012-02-28
  5. 2012/02/28 01:45:28 - 2012-02-28