// ==UserScript== // @name 115网盘显示文件SHA1 // @namespace com.115wangpan.showsha1 // @version 0.8 // @description 显示网盘文件SHA1哈希值、批量复制文件SHA1值 // @author YIU // @icon http://115.com/favicon.ico // @match http*://115.com/*ct=file* // @grant unsafeWindow // @run-at document-end // @downloadURL none // ==/UserScript== let $ = unsafeWindow.$; //* 显示SHA1(要显示的元素,列表类型[0列表型,1图标型]) function displaySha1(dom, listType){ //由事件传入的dom元素可能是任何标签,只对含有sha1的文件元素显示sha1 if(!dom.hasAttribute('sha1')){ return; } var sha1 = $(dom).attr('sha1'); if(listType){ //图标型、无法直接显示、只能在提示中显示 if($(dom).find('em[gmflagsha1]').length > 0){ $(dom).find('em[gmflagsha1]').remove(); $(dom).find('em').css('padding-top',''); $(dom).find('.file-name').css('height',''); $(dom).find('.file-name').css('position',''); } if(dom.title.indexOf('\r')<1){ var title = `\r\n${sha1}`; dom.title += title; $(dom).find('.file-name .name')[0].title += title; } } else if(listType < 1 && $(dom).find('em[gmflagsha1]').length < 1){ //列表型 $(dom).find('.file-name').css('position','initial'); $(dom).find('.file-name').css('height','50px'); $(dom).find('em').css('padding-top','6px'); $(dom).find('.file-name').append(`${sha1}`); } } //复制SHA1界面方法 let UI_CopySHA1 = { 'ui': null, 'hasBind': false, 'createCopy': function(type){ let content = ''; let contentTitle = ''; let checkedItems = $('#js_data_list input[checked="checked"]').parent(); checkedItems.each(function(){ if(!this.hasAttribute('sha1')){return;} contentTitle = $(this).parents('.list-thumb').length > 0 ? $(this).attr('title').split('\n')[0] : $(this).attr('title'); switch(type){ case 1: content += `${contentTitle}\n${$(this).attr('sha1')}\n\n`;break; case 2: content += `${$(this).attr('sha1')}#${contentTitle}\n`;break; default: content += `${$(this).attr('sha1')}\n`; } }); return content; }, 'copySHA1': function(e, type){ unsafeWindow.oofUtil.plug.copy.initNewCopy({ btn_parent: e, txt: function(){ return UI_CopySHA1.createCopy(type); }, suc: function(){ return unsafeWindow.TOP.Core.MinMessage.Show({ text: "复制成功", type: "suc", timeout: 2e3 }); } }); }, 'show': function(show){ if(!this.ui){ this.createUI(); } if(show){ this.ui.show(); } else{ this.ui.hide(); } }, 'createUI': function(){ if($('.header-name [gmflagcopysha1ui]').length > 0){return;} let hookmenu = false; let addmenu = $(`
`).hover( function(){ hookmenu = !0; }, function(){ hookmenu = !1; setTimeout(function(){ if(!hookmenu){addmenu.css('display','none');} },200); }); let addmenuitem = $(`