imgur.direct

Adds image direct link for imgur uploads.

2016/08/04のページです。最新版はこちら

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         imgur.direct
// @namespace    imgurdir
// @version      0.1.0
// @description  Adds image direct link for imgur uploads.
// @author       Jakub Rychecký <[email protected]>
// @license      WTFPL 2
// @include      *imgur.com*
// ==/UserScript==


create_direct();




function create_direct(){
    $('.post-image-container').each(function(){ // Every image container
      var img = $(this);
        
      if(!has_direct_link(img) && is_image_ready(img)){ // Doesn't have direct link yet and image is fully uploaded...
          write_direct_link(img);   
      }
    });
    
    setTimeout(create_direct, 500); // Let's repeat
}



function get_direct_link(img){
   var link = img.find('a.zoom').attr('href'); // Link from zoom
   link = 'http:'+link;
    
   return link;
}


function is_image_ready(img){
  var link = get_direct_link(img);
    
  return link.indexOf('undefined') == -1 && link.indexOf('blob') == -1;
}


function has_direct_link(img){
  return img.find('.direct').length > 0;
}

function write_direct_link(img){
   var css = { // CSS for textarea
     'width': '100%',
     'background': '#2C2F34',
     'text-align': 'center',
     'font-weight': 'bold',
     'font-size': '0.8em',
     'height': '28px',
     'margin-bottom': '0px'
   }
    
   var html = $('<textarea onclick="$(this).select()">'+get_direct_link(img)+'</textarea>'); // Direct link textarea
    
   html.addClass('direct').css(css);
    
   img.prepend(html);
}