// ==UserScript== // @name 考古加助手 // @namespace https://greasyfork.org/zh-CN/scripts/481619-考古加助手 // @version 1.1 // @license GPL-3.0 // @description 增强考古加能力 // @author wzhjm // @match https://*.kaogujia.com/* // @icon https://raw.githubusercontent.com/wzhjm/MWeb_Image/main/202312072020007.ico // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; var t, s, a, n; t = document.createElement("script");; t.src = "https://zeptojs.com/zepto.min.js" document.body.appendChild(t); s = document.createElement("script"); s.src = "https://www.itxst.com/package/clipboardjs/clipboard.min.js" document.body.appendChild(s); var new_element = document.createElement('link'); new_element.setAttribute('rel', 'stylesheet'); //注:这里currentScript的写法不兼容IE new_element.setAttribute('href', 'https://unpkg.com/element-ui/lib/theme-chalk/index.css'); document.body.appendChild(new_element); var copyTxt=function(text){ if(typeof document.execCommand!=="function"){ alert("复制失败,请长按复制"); return; } var dom = document.createElement("textarea"); dom.value = text; dom.setAttribute('style', 'display: block;width: 1px;height: 1px;'); document.body.appendChild(dom); dom.select(); var result = document.execCommand('copy'); document.body.removeChild(dom); if (result) { alert("复制成功"); return; } if(typeof document.createRange!=="function"){ alert("复制失败,请长按复制"); return; } var range = document.createRange(); var div=document.createElement('div'); div.innerHTML=text; div.setAttribute('style', 'height: 1px;fontSize: 1px;overflow: hidden;'); document.body.appendChild(div); range.selectNode(div); const selection = window.getSelection(); if (selection.rangeCount > 0){ selection.removeAllRanges(); } selection.addRange(range); document.execCommand('copy'); alert("复制成功") } var videoListFunction = function () { // 等待zepto加载完,再执行 if ($('.pc-icon-player') && $('.pc-icon-player').forEach) { $('body').append(''); new ClipboardJS('#urlClipboard'); //全局变量 var originOpen = window.open; var copyOpen = function (url) { //将链接转化成原视频链接 url = url.replaceAll('\/share', '').replaceAll('?', ''); $('#urlClipboard').data('clipboard-text', url); $('#urlClipboard').click(); console.log("已复制:" + url); } $('body').on('click', '.check-item', function () { if ($(this).hasClass('el-icon-check')) { $(this).removeClass('el-icon-check') } else { $(this).addClass('el-icon-check') } changeSelect() }) //添加浮动的选择按钮 $('body').append(`
全选
`) $('body').on('click', '.select-all', function () { //获取所有 var has_select = false; $('.check-item').forEach(item => { if ($(item).hasClass('el-icon-check')) { has_select = true } }) if (has_select) { //有选择,全部取消 $('.check-item').forEach(item => { $(item).removeClass('el-icon-check') }) } else { //为空,全选 $('.check-item').forEach(item => { $(item).addClass('el-icon-check') }) } $(this).text(!has_select ? "取消选中" : "全选") }) var changeSelect = function () { var has_select = false; $('.check-item').forEach(item => { if ($(item).hasClass('el-icon-check')) { has_select = true } }) console.log('changeSelect', !has_select ? "取消选中" : "全选") $('.select-all').text(has_select ? "取消选中" : "全选") } //添加浮动的选择复制按钮 $('body').append(`
复制选中
`) //复制选择 $('body').on('click', '.copy-all', function () { var copy_list = [] window.open = function (url) { //将链接转化成原视频链接 url = url.replaceAll('\/share', '').replaceAll('?', ''); copy_list.push(url) } //获取所有 $('.check-item').forEach(item => { if ($(item).hasClass('el-icon-check')) { $(item).prev().prev().click() } }) //复制完成,恢复 window.open window.open = originOpen if (copy_list.length > 0) { copyOpen(copy_list.join('\n')) } setTimeout(() => { if (copy_list.length > 0) { $(this).text('复制成功') $(this).css('color', '#67C23A') //复制成功,取消所有选择 $('.check-item').forEach(item => { $(item).removeClass('el-icon-check') }) changeSelect() } else { $(this).text('没有选择') $(this).css('color', '#F56C6C') } setTimeout(() => { $(this).text('复制选中').css('color', '#4975e9') }, 2000) }, 1000) }) setInterval(() => { $('.goods-box').forEach(pro => { let is_has = $(pro).parent().find('.cover-click') if (is_has.length == 0) { $(pro).parent().css('position', 'relative') //添加相关视频按钮 $(pro).parent().append( `
关联视频
` ) } }) let player_ele = [] if (location.pathname === '/darenDetails/videoWorks') { //达人视频作品页面 player_ele = $('.handle-area .svg:nth-child(2) svg') //调整表格样式 $("colgroup").forEach(col => { $(col).children().forEach((item, index) => { if (index > 1 && index < 8) { $(item).attr('width', 80) } if (index == 8) { $(item).attr('width', 126) } }) }) $('thead > tr').children().forEach((item, index) => { if (index > 1 && index < 8) { $(item).css('width', 80) $(item).attr('width', 80) } if (index == 8) { $(item).css('width', 126) $(item).attr('width', 126) } }) $('tbody > tr').children().forEach((item, index) => { if (index > 1 && index < 8) { $(item).css('width', 80) $(item).attr('width', 80) } if (index == 8) { $(item).css('width', 126) $(item).attr('width', 126) } }) player_ele.forEach(player => { $(player).parent().css('display', 'flex') $(player).parent().css('align-items', 'center') }) } else { player_ele = $('.collect-icon') } player_ele.forEach(function (player) { let is_has = $(player).parent().find('.has-check-item') //避免因问懒加载的原因导致一些元素没有插入,已经插入的就不需要再次插入。 if (is_has.length === 0) { $(player).after( ''); $(player).after( ''); } }); }, 1000) let searchGoods = function (goods_name) { //将goods_name放到搜索框搜索 $($('.search-container').find('.cancel-input-default')[0]).val(goods_name) $('.search-container').find('.cancel-input-default')[0].dispatchEvent(new Event('input')) setTimeout(() => { $('.search-container .search-icon').click() }, 600) } $('body').on('click', '.cover-click', function () { //获取点击的 title let title = $(this).parent().find('.title').text() console.log('title', title) searchGoods(title) }) let query = {} location.search.replace("?", "").split("&").forEach(kv => { let k_v = kv.split("=") query[k_v[0]] = k_v[1] }) if (query.goods_name) { let goods_name = decodeURIComponent(query.goods_name) console.log('goods_name', goods_name) let temp_int = setInterval(() => { searchGoods(goods_name) clearInterval(temp_int) }, 400) } } } var productOverviewFunction = function () { let is_has = $('.line-tabs-box').find('.search-video') if (is_has.length == 0) { let goods_name = $('.title-box').find('.title').text() if ($('.line-tabs-box').find('.search-video').length === 0) { $($('.line-tabs-box').children()[3]).after( `` ) } } } var productListFunction = function () { setInterval(() => { $('.list-export-item').forEach(pro => { let is_has = $(pro).parent().find('.cover-click') if (is_has.length == 0) { let goods_name = $(pro).find('.title').text() $(pro).parent().css('position', 'relative') //添加相关视频按钮 $(pro).parent().append( `
关联视频
` ) } }) }, 1000) } var productAnalysisFunction = function () { setInterval(() => { $('.goods-export').forEach(pro => { let is_has = $(pro).parent().find('.cover-click') if (is_has.length == 0) { let goods_name = $(pro).find('.desc').text() $(pro).parent().css('position', 'relative') //添加相关视频按钮 $(pro).parent().append( `
关联视频
` ) } }) }, 1000) } window.onload = () => { var init_list = { "/darenSquare/productList": { init: false, page_load: productListFunction, }, "/darenSquare/videoList": { init: false, page_load: videoListFunction, }, "/darenDetails/videoWorks": { init: false, page_load: videoListFunction, }, "/darenDetails/productAnalysis": { init: false, page_load: productAnalysisFunction, }, "/productDetails/productOverview": { init: false, page_load: productOverviewFunction, }, "/productDetails/linkDaren": { init: false, page_load: productOverviewFunction, }, "/productDetails/linkLive": { init: false, page_load: productOverviewFunction, }, "/productDetails/linkVideo": { init: false, page_load: productOverviewFunction, }, "/productDetails/productFansPortrait": { init: false, page_load: productOverviewFunction, } } console.log('init_list', init_list) //每个页面有指定的函数,到了这个页面才加载页面函数 var page_object = init_list[location.pathname] console.log('location.href', location.pathname) console.log('init', page_object.init) if (page_object && !page_object.init) { //未初始化 setTimeout(page_object.page_load, 1000) page_object.init = true } //其他页面 init 切换成false for (let href in init_list) { if (href !== location.pathname && init_list[href].init == true) { console.log(href + ' false') init_list[href].init = false } } } })();