// ==UserScript==
// @name 115美剧天堂
// @namespace http://www.51fxiang.com/
// @version 1.0.0
// @description 加入批量复制链接功能,一个一个链接复制太TM蛋碎了。。
// @author 51fixang.com
// @match *://*.115mj.com/*
// @require https://code.jquery.com/jquery-latest.js
// @require https://greasyfork.org/scripts/398993-%E5%A4%8D%E5%88%B6%E8%84%9A%E6%9C%AC/code/%E5%A4%8D%E5%88%B6%E8%84%9A%E6%9C%AC.js?version=785875
// @note 2020-03-30 1.0.0 初版发布
// @grant none
// @downloadURL none
// ==/UserScript==
var obj_51fxiang={
addcheckbox:function (){
//alert("dddd");
$(".mox").each(function(i){
//添加各项的checkbox
$(this).find(".dwww").prepend(" ");
//添加操作按钮
$(this).find("ul").append("
全选 等待复制
")
});
},
selectall:function(){
$("input[class^='dwww_all_']").change(function(){
var dwww_ = "."+$(this).attr("name");
if($(this).is(":checked"))
{
$(dwww_).prop("checked","checked");
}
else
{
$(dwww_).removeAttr("checked");
}
});
},
copylink:function(){
$("input[class^='dwww_link_']").click(function(i){
var dwww_ = "."+$(this).attr("name");
var links = "";
var count = 0;
$(dwww_).each(function(){
if($(this).is(":checked"))
{
links+=$(this).next().attr("href")+"\r\n";
count++;
}
});
var spanid = "#"+$(this).attr("spanid");
var h_id = "#"+$(this).attr("hid");
$(h_id).val(links);
//alert($(h_id).val());
//obj_51fxiang.copy(links);
var clipboard = new ClipboardJS("."+$(this).attr("class"), {
text: function() {
return $(h_id).val();
}
});
clipboard.on('success', function(e) {
//alert("复制成功");
$(spanid).text("共"+count+"项 复制成功");
e.clearSelection();
});
clipboard.on('error', function(e) {
alert("复制失败"+e.action+"|"+e.trigger+"|"+e.text);
});
if(links!='')
{
$(spanid).click(function(){
obj_51fxiang.dialog(links);
});
}
});
},
dialog:function(msg){
//http://www.hanwq.com/scripts/artdialog/dialog-plus-min.js
//var d = dialog({
// title: '粘贴信息',
// content: msg
//});
//d.showModal();
alert(msg);
},
copy:function copyToClipboard(txt) {
if (window.clipboardData) {
window.clipboardData.clearData();
clipboardData.setData("Text", txt);
alert("复制成功!");
} else if (navigator.userAgent.indexOf("Opera") != -1) {
window.location = txt;
} else if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert("被浏览器拒绝!\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");
}
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip)
return;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans)
return;
trans.addDataFlavor("text/unicode");
var str = new Object();
var len = new Object();
str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var copytext = txt;
str.data = copytext;
trans.setTransferData("text/unicode", str, copytext.length * 2);
var clipid = Components.interfaces.nsIClipboard;
if (!clip)
return false;
clip.setData(trans, null, clipid.kGlobalClipboard);
alert("复制成功!");
}
}
};
(function() {
'use strict';
obj_51fxiang.addcheckbox();
obj_51fxiang.selectall();
obj_51fxiang.copylink();
})();