微博图片原图地址批量复制

点击下方的“复制”链接后,就可粘贴到贴吧或者迅雷批量下载

Verzia zo dňa 15.08.2015. Pozri najnovšiu verziu.

// ==UserScript==
// @name            微博图片原图地址批量复制
// @description     点击下方的“复制”链接后,就可粘贴到贴吧或者迅雷批量下载
// @include         http://www.weibo.com/*
// @version         0.5
// @author          yechenyin
// @namespace	      https://greasyfork.org/users/3586-yechenyin
// @require	        https://code.jquery.com/jquery-1.11.2.min.js
// @grant           GM_setClipboard
// ==/UserScript==


$(document).ready(function() {
    var script = document.createElement('script');
    script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";
    document.getElementsByTagName("head")[0].appendChild(script);

console.log('script start work');
if (!location.href.indexOf("http://www.weibo.com/")) {
  block = "unlock";
  $(document).on('DOMNodeInserted', '#plc_main', function (event) {
    if (block != 'lock') {
    block = 'lock';

    $('.WB_row_line li').loaded(function () {
      console.log($('.WB_row_line').length);
      for (var i=0; i<$('.WB_row_line').length; i++) {
        if ($('.WB_row_line').eq(i).find('.copy_images').length === 0)
        $('.WB_row_line').eq(i).html('<li class="copy_images"><a class="S_txt2"><span class="S_line1 line">复制</span></a></li>'+$('.WB_row_line').eq(i).html());
      }
      setTimeout(function () {
        window.block = "unlock";
        console.log(window.block);
      }, 500);

      $('.WB_row_line li').css({width:"20%"});
      $('.copy_images').click(function () {
        urls = '';
        var images = $(this).parent().parent().parent().parent().find('.WB_media_a img');
        for (var i=0; i<images.length; i++) {
          urls += images[i].src + '\n';
        }
        urls = urls.replace(/\/square\//g, '/large/');
        console.log(urls);
        GM_setClipboard(urls);

      });
    });

    }
  });
}


});


jQuery.fn.loaded = function (action) {
    var target = this;
    if ($(this.selector).length > 0)
        action();
    else
        setTimeout(function() {target.loaded(action);}, 300);
};