Greasy Fork

Greasy Fork is available in English.

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

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

当前为 2015-09-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

add_text = false; //如果想要同时复制文字,请将false为true。否则将true改为false

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

if (!location.href.indexOf("http://www.weibo.com/")) {
  block = "unlock";
  add_copy_links();
  $(document).on('DOMNodeInserted', '#plc_main', add_copy_links);
}


function add_copy_links() {
  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) {
        html = $('.WB_row_line').eq(i).html().substr(0, $('.WB_row_line').eq(i).html().indexOf('</li>'));
        html += '<li class="copy_images"><a class="S_txt2"><span class="S_line1 line">复制</span></a></li>';
        html += $('.WB_row_line').eq(i).html().substr($('.WB_row_line').eq(i).html().indexOf('</li>'));
        $('.WB_row_line').eq(i).html(html);
      }
    }
    setTimeout(function () {
      window.block = "unlock";
      console.log(window.block);
    }, 300);

    $('.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/');
      urls = urls.replace(/\/thumbnail\//g, '/large/');
      console.log(urls);
      var text = $(this).parent().parent().parent().parent().find('.WB_text').text();
      console.log(text);
      text = text.replace(/^\s+/, '').replace(/\s+$/, '');
      if (!add_text)
        text = '';
      GM_setClipboard(text + urls);

    });
  });

  }
}