// ==UserScript== // @name 企查查、爱企查、天眼查专利列表下载 // @namespace http://tampermonkey.net/ // @version 4.3 // @description 下载企查查、爱企查、天眼查的专利列表,页面显示专利信息即可下载。 // @author angeljhon // @match *://www.qcc.com/*/* // @match *://www.tianyancha.com/*/* // @match *://aiqicha.baidu.com/* // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_setValue // @grant GM_getValue // @connect www.qcc.com // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/467858/%E4%BC%81%E6%9F%A5%E6%9F%A5%E3%80%81%E7%88%B1%E4%BC%81%E6%9F%A5%E3%80%81%E5%A4%A9%E7%9C%BC%E6%9F%A5%E4%B8%93%E5%88%A9%E5%88%97%E8%A1%A8%E4%B8%8B%E8%BD%BD.user.js // @updateURL https://update.greasyfork.icu/scripts/467858/%E4%BC%81%E6%9F%A5%E6%9F%A5%E3%80%81%E7%88%B1%E4%BC%81%E6%9F%A5%E3%80%81%E5%A4%A9%E7%9C%BC%E6%9F%A5%E4%B8%93%E5%88%A9%E5%88%97%E8%A1%A8%E4%B8%8B%E8%BD%BD.meta.js // ==/UserScript== if(GM_getValue('down_zy',null) == null){ GM_setValue('down_zy',0); } if(GM_getValue('get_de',null) == null){ GM_setValue('get_de',200); } const menu_command_id0 = GM_registerMenuCommand('设置间隔,只有获取摘要时影响',function(){ var input_f=document.createElement('div'); input_f.style.position = 'fixed'; input_f.style.top = '50px'; input_f.style.right='50px'; input_f.style.width='150px'; input_f.style.height='100px'; input_f.style.background = 'blue'; input_f.style.color = 'black'; input_f.style.zIndex = '9999'; input_f.innerHTML = `

输入数据,单位毫秒

`; var btn=document.createElement('button'); btn.style.position = 'absolute'; btn.style.left='55px'; btn.style.top='60px'; btn.style.width = '40px'; btn.style.height= '30px'; btn.style.background= 'black'; input_f.style.color = 'white'; btn.innerHTML = '确定'; btn.onclick = function(){ var input_v = document.getElementById('input_v').value; GM_setValue('get_de',input_v); input_f.remove(); } input_f.appendChild(btn) document.body.appendChild(input_f) },'t'); function t_b(){ if(GM_getValue('down_zy') == 1){ return '是'; }else{ return '否'; } } function change_menu(){ var menu_command_id = GM_registerMenuCommand(`点击改变下载摘要状态【${t_b()}】`, function() { if(GM_getValue('down_zy') == 1){ GM_setValue('down_zy',0); }else{ GM_setValue('down_zy',1); } GM_unregisterMenuCommand(menu_command_id); change_menu(); }, "a"); } change_menu(); function sleep(delay) { var start = (new Date()).getTime(); while((new Date()).getTime() - start < delay) { continue; } } //生成从minNum到maxNum的随机数 function randomNum(minNum,maxNum){ switch(arguments.length){ case 1: return Math.ceil(parseInt(Math.random()*minNum+1,10)); break; case 2: return Math.ceil(parseInt(Math.random()*(maxNum-minNum+1)+minNum,10)); break; default: return 0; break; } } async function fetchPageWithFetch(url,ind) { try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return {'html':await response.text(),'i':ind}; } catch (error) { throw error; // 抛出错误以供外部处理 } } (function() { 'use strict'; // Create a new button element const button = document.createElement('button'); button.innerText = '下载'; // Change the button style button.style.backgroundColor = 'black'; button.style.color = 'white'; button.style.position = 'fixed'; button.style.bottom = '20px'; button.style.right = '5px'; button.style.zIndex = '9999'; button.style.width ='60px'; button.style.height = '30px'; // Add the button to the page document.body.appendChild(button); var dl_name="专利列表.xls"; var c_name=""; // Add a click event listener to the button button.addEventListener('click', () => { var exportFileContent=""; if(document.URL.search('qcc.com')!=-1){ var e_s=document.querySelector("#zhuanlilist"); var hh = e_s.querySelectorAll("span.tbadge")[1].textContent; //var e_li = e_lu.querySelectorAll("li.active"); var e_lu =e_s.querySelector("ul.pagination"); var e_li = e_lu.querySelectorAll("li"); if(e_lu.querySelector("li.active").querySelector("a").textContent.replaceAll(' ','').replaceAll('\n','')!="1"){ for(var i=0;i','摘要'); }else{ exportFileContent = exportFileContent + te_l[0].outerHTML; } for(i=1;i { // console.log(te_l[data.i]); // 打印获取到的网页内容 var parser = new DOMParser(); var doc = parser.parseFromString(data.html, "text/html"); var doc_titles = doc.querySelectorAll('div.sub-title'); for(var j=0;j',`${zy}`); }else if(j==doc_titles.length-1){ exportFileContent = exportFileContent + te_l[data.i].outerHTML.replace('',` `); } } }) .catch(error => { console.error(error); // 打印错误信息 }); sleep(GM_getValue('get_de',200)); }else{ exportFileContent = exportFileContent + te_l[i].outerHTML; } } }else if(document.URL.search('tianyancha')!=-1){ var targetText="专利名称"; var ts_e= document.getElementsByClassName('table-wrap'); ww1:{ for(var i3=0;i3 { // console.log(te_l[data.i]); // 打印获取到的网页内容 var parser = new DOMParser(); var doc = parser.parseFromString(data.html, "text/html"); var doc_titles = doc.querySelectorAll('div.sub-title'); for(var j=0;j',`${zy}`); }else if(j==doc_titles.length-1){ exportFileContent = exportFileContent + te_l[data.i].outerHTML.replace('',` `); } } }) .catch(error => { console.error(error); // 打印错误信息 }); sleep(GM_getValue('get_de',200)); }else{ exportFileContent = exportFileContent + te_l[i].outerHTML; } } che0=che1; } e_lu =e_s.querySelector("ul.pagination"); var e_li = e_lu.querySelectorAll("li"); var flag=0; for(i=0;i"){ a_t.click(); console.log(cou); cou++; flag=1; } } }else if(document.URL.search('tianyancha')!=-1){ var targetText="专利名称"; var ts_e= document.getElementsByClassName('table-wrap'); ww1:{ for(var i1=0;i1 ',''); exportFileContent='
序号 发明名称 专利类型 法律状态 申请号 申请日期 公开(公告)号 公开(公告)日期 发明人 内容
'+exportFileContent+'
'; }else if(document.URL.search('aiqicha.baidu')!=-1){ c_name =document.querySelector(".name").textContent; dl_name=c_name+"_爱企查_专利列表.xls"; exportFileContent=exportFileContent.replaceAll('',''); }else if(document.URL.search('tianyancha')!=-1){ c_name =document.querySelector(".index_company-name__LqKlo").textContent; dl_name=c_name+"_天眼查_专利列表.xls"; exportFileContent=exportFileContent.replaceAll('
序号专利名称公布/公告号专利类型公布/公告日期操作
',''); } if(exportFileContent != undefined){ //使用Blob var blob = new Blob([exportFileContent], {type: "text/plain;charset=utf-8"});//解决中文乱码问题 blob = new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type}); //设置链接 var link = window.URL.createObjectURL(blob); var a = document.createElement("a"); //a.download = "专利列表.xls"; a.download = dl_name; a.href = link; document.body.appendChild(a); a.click(); document.body.removeChild(a); }else{ alert("下载失败!"); } } }, randomNum(800,2000));//这里是翻页的间隔速度,会随机从800-2000,单位ms }); })();
序号申请日专利名称专利类型专利状态申请号公开(公布)号公开(公告)日发明人操作