Twitter画像Downloadリンク追加

    @@ -10,8 +10,13 @@ 'use strict'; -var img_url = w.location.href, - filename = img_url.replace( /^.+\/([^\/.]+)\.(\w+):(\w+)$/, '$1-$3.$2' ), +var img_url = w.location.href; + +if ( ! ( img_url.match( /^https?:\/\/pbs\.twimg\.com\/media\// ) ) ) { + return; +} + +var filename = img_url.replace( /^.+\/([^\/.]+)\.(\w+):(\w+)$/, '$1-$3.$2' ), link = d.createElement('a'), container = d.createElement('p'), link_style = link.style;
  • /*
     * @title Twitter画像Downloadリンク追加
     * @description Twitterの画像を開いた画面に、download属性付きのリンクを追加(*.jpg:orig→-*-orig.jpg)
     * @include https://pbs.twimg.com/media/*
     * @license MIT License
     * @javascript_url
     */
     
    ( function ( w, d ) {
    
    'use strict';
    
    var img_url = w.location.href;
    
    if ( ! ( img_url.match( /^https?:\/\/pbs\.twimg\.com\/media\// ) ) ) {
    	return;
    }
    
    var filename = img_url.replace( /^.+\/([^\/.]+)\.(\w+):(\w+)$/, '$1-$3.$2' ),
        link = d.createElement('a'),
        container = d.createElement('p'),
        link_style = link.style;
    
    link_style.color = '#000';
    link_style.background = '#FFF';
    link.href = img_url;
    link.innerHTML = 'Download';
    link.download = filename;
    container.appendChild( link );
    d.body.insertBefore( container, d.body.firstChild );
    } )( window, document );
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2016/01/16 01:56:16 - 2016-01-16
  2. 2016/01/16 01:23:45 - 2016-01-16