Greasy Fork

Greasy Fork is available in English.

display the image of tumblr in HD revolution and copy http url of images in one post

直接显示tumblr的图片为高清版,并可以复制一个博文的所有图片地址

当前为 2015-08-26 提交的版本,查看 最新版本

// ==UserScript==
// @name         display the image of tumblr in HD revolution and copy http url of images in one post
// @description  直接显示tumblr的图片为高清版,并可以复制一个博文的所有图片地址
// @version      0.7
// @include      http://*.tumblr.com/*
// @include      https://*.tumblr.com/*
// @author       yechenyin
// @namespace    http://greasyfork.icu/users/3586-yechenyin
// @require  	   https://code.jquery.com/jquery-1.11.2.min.js
// @grant        GM_setClipboard
// ==/UserScript==
var script = document.createElement('script');
script.src = "https://code.jquery.com/jquery-1.11.2.min.js";
document.getElementsByTagName("head")[0].appendChild(script);

$(".post_wrapper").each(function() {
  if ($(this).find(".post_media img").length > 0) {
    $(this).find(".photoset_photo img").each(function() {
      if (this.src != this.parentNode.href)
      	this.src = this.parentNode.href;
    });
    $(this).find(".post_media_photo").each(function() {
      if ($(this).parent().attr("data-big-photo") && this.src != $(this).parent().attr("data-big-photo")) {
        this.src = $(this).parent().attr("data-big-photo");
        console.log(this.src);
      }
    });

        $(this).find(".post_notes_label").eq(0).after($("<span>", {text:"copy images", class:"copy_images",  css:{display:"inline", cursor:"pointer"}}));
        $(".note_link_current").css({display:"inline", marginRight:"10px"});
        if ($(this).find(".copy_images").length > 0)
          console.log('added copy images');

        //http_images = window.open('');
        //http_images.document.write('<img src="http://40.media.tumblr.com/6379bf498cbe12e443a1607b61c93095/tumblr_nrowugNmuu1tl5dtco1_1280.jpg">
        //<img src="http://41.media.tumblr.com/10834d9c88c31050e1e5e781ac0e0b5a/tumblr_nma283eQgQ1u418bgo10_540.jpg">');
  }
});
$(document).on('click', '.copy_images', copy_images);

//$(document).on('DOMNodeInserted', 'body', function(e) {
  //console.log(e.target.tagName + " "+ e.target.className);
//});

$(document).on('DOMNodeInserted', '.post_container', function(e) {
  if ($(e.target).hasClass('post_container')) {
      //console.log($(this).html());
      //setTimeout(function(){console.log($(this).find(".post_notes_label").length)}, 3000);
        if ($(this).find(".post_media img").length > 0) {
          $(this).find(".photoset_photo img").each(function() {
            if (this.src != this.parentNode.href)
            	this.src = this.parentNode.href;
          });
          $(this).find(".post_media_photo").each(function() {
            if ($(this).parent().attr("data-big-photo") && this.src != $(this).parent().attr("data-big-photo")) {
              this.src = $(this).parent().attr("data-big-photo");
              console.log(this.src);
            }
          });

          $(this).find(".post_notes_label").eq(0).after($("<span>", {text:"copy images", class:"copy_images",  css:{display:"inline", cursor:"pointer"}}));
          $(".note_link_current").css({display:"inline", marginRight:"10px"});
          if ($(this).find(".copy_images").length > 0)
            console.log('added copy images');

        }
  }
});


function copy_images() {
  images='';
  //var index = $(".copy_images").index(this);
  //console.log('index:' +index);
  $(this).parents('.post_wrapper').find("a>img").each(function() {
    images += this.src.replace(/https:\/\//g, "http://") + '\n';
  });
  if (typeof GM_setClipboard === "undefined")
    console.log('images:' +images);
  else
    GM_setClipboard(images);
}