Chrome/Firefox による GIF のダウンロードを停止するにはどうすればよいですか?

Chrome/Firefox による GIF のダウンロードを停止するにはどうすればよいですか?

アニメーションを含むページgif(Google+、9gagなど)にアクセスすると、それらすべてが読み込みを開始するようです。帯域幅が限られているため、本当に見たい場合を除いてダウンロードしたくありません。停止するプラグインもいくつかあります。アニメーションしかし、画像自体はダウンロードとにかく、9gag.com には当初この機能がありましたが、静止画像 (アニメーション GIF の場合) が表示され、クリックした後にのみダウンロードが開始されました (現在は削除されています)。

それで、それを止めることができるプラグインはありますか?ダウンロード中gif ですか? それとも、拡張機能を記述する必要がありますか? 何か提案はありますか?

答え1

まだ適切な拡張機能/プラグインがありません。次のユーザースクリプトを使用してみました。タンパーモンキーChrome で。うまく機能しています。9gag.com のサイトにあるすべての GIF (Ajax GIF を含む) をブロックしています。何らかの理由で、Google+ の Ajax GIF はブロックされません (調査中)。シネテック彼の助け、努力、そしてコードに感謝します。これがユーザースクリプトです(スクリプトのほとんどはSynetec のユーザースクリプト):

// ==UserScript==
// @name       gifBlock
// @namespace  http://i.have.no.homepage/
// @version    0.1
// @description  Stops downloading gif images (including ajax gifs) in 9gag.com (or any page if you just fix the @match rule)
// @match      http://*.9gag.com
// @copyright  2012+, Nobody
// ==/UserScript==

function tamperMonkeyWrap()
{   
    function log(m)
    {
        console.log(m);
    }
    function jQWrap($)
    {
        log("Extension execution begins...");

        function blockGifs()
        {        
            $('img').each(function() {
                var $img = $(this),
                    src = $img.attr('src'),
                    w = $img.width(),
                    h = $img.height(),
                    cursor = $img.css('cursor'),
                    parts = src.split('.'),
                    ext = parts[parts.length-1];

                if ($.trim(ext.toLowerCase()) != "gif")
                    return;            

                $img.attr('data-imgurl', src);
                $img.data('cursor', cursor);
                $img.css('cursor', 'pointer');
                $img.addClass('gif-blocked');                
                h = h > 100? h : 100;
                $img.attr('src', '//ipsumimage.appspot.com/'+w+'x'+h+'?l=Gif (Click)');
            }); 
        }

        function interceptAjax () {
            $('body').ajaxComplete(
                function (event, requestData)
                {
                    log("Blocking GIF [Ajax] ...");                
                    blockGifs();
                }
            );
        }

        $(document).ready(function() {
            log("Blocking GIF [Ready]....");
            blockGifs();
            interceptAjax();        
            $(document).on('click', 'img.gif-blocked', function(ev) {            
                var $img = $(this),
                    url = $img.attr('data-imgurl'),
                    cursor = $img.data('cursor');

                $img.attr('src', url);
                $img.css('cursor', cursor);
                $img.removeClass('gif-blocked');
                ev.preventDefault();
                return false;
            });  
        });

        log("Document is not ready yet. trying block just in case it takes time to be _ready_ (google+).");
        blockGifs();
    }

    if (window.jQuery == undefined)
    {
        log("Loading jQuery...");
        var scriptTag = document.createElement('script');
        scriptTag.src = "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";
        scriptTag.onload = function(){
            log("jQuery loaded.");
            window.jQuery = jQuery; 
            jQWrap(jQuery);
        };
        document.getElementsByTagName('head')[0].appendChild(scriptTag);
    }
    else
    {
        log("jQuery already included in the page");
        jQWrap(window.jQuery);
    }   
}

var scriptTag = document.createElement('script');
scriptTag.text = '(' + tamperMonkeyWrap.toString() + ')();';
document.getElementsByTagName('head')[0].appendChild(scriptTag);

今:

  1. TamperMonkeyをインストールする
  2. ダッシュボードに進め
  3. 「新しいスクリプト」をクリックします
  4. 上記のコードを貼り付けます
  5. 保存して、動作するかどうかを確認します。(現在は 9gag.com でのみ動作します。ただし、@match任意のサイトに合わせてディレクティブを変更できます。 を使用すると、すべてのサイト (http) で動作します。 を使用すると、セキュリティで保護された http サイト (例: google+) で@match http://*/*動作します)https

答え2

素晴らしい Firefox アドオン:

adblock - 広告をインテリジェントにブロック

flashblock - クリックしない限り、すべてのフラッシュはブロックされます

imgblock - あらゆる場所ですべての画像をブロックします (クリックすると一時的に無効にできます)

ghostery - ソーシャル ネットワーキング サイトをブロックします (ページ訪問ごとに数百 KB 以上のトラフィックを生成できます)

関連情報