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

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

目前为 2015-08-13 提交的版本。查看 最新版本

// ==UserScript==
// @name            微博图片原图地址批量复制
// @description     点击下方的“复制”链接后,就可粘贴到贴吧或者迅雷批量下载
// @include         http://www.weibo.com/*
// @version         0.2
// @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() {
console.log('script start work');
if (!location.href.indexOf("http://www.weibo.com/")) {
  executeAfterLoaded('.WB_row_line li', add_copy_link);
  //$(document).on('DOMNodeInserted', '#plc_main', add_copy_link);
}

function add_copy_link() {
  console.log($('.WB_row_line li').length);
  for (var i=0; i<$('.WB_row_line').length; i++) {
    $('.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());
  }
  $('.WB_row_line li').css({width:"20%"});

  $('.copy_images').click(function () {
    urls = '';
    var images = $(this).parent().parent().parent().parent().find('.WB_media_a img');
    //images;
    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);
  });
}


function executeAfterLoaded(element, action) {
    if ($(element).length === 0) {
        setTimeout(function() {executeAfterLoaded(element, action);}, 200);
    }
    else {
	     console.log(element + $(element).length);
        action();
    }
}

});