Greasy Fork镜像 支持简体中文。

快速复制

快速复制企业信息

  1. // ==UserScript==
  2. // @license MIT
  3. // @name 快速复制
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.0
  6. // @description 快速复制企业信息
  7. // @author lemondqs
  8. // @match https://www.tianyancha.com/company/**
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=tianyancha.com
  10. // @grant none
  11.  
  12. // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.3/jquery.js
  13. /* globals jQuery, $, waitForKeyElements */
  14.  
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. // 'use strict';
  19. setTimeout(function(){
  20.  
  21.  
  22. // 提前展开页面 保障信息完整
  23. $('.introduceRich_btn__sfAyp').click()
  24.  
  25. // 获取行业信息
  26. function gethyinfo() {
  27. var hy = '';
  28. let hyidx = null;
  29. $('.index_tableBox__ZadJW tr').each((idx, tr)=>{
  30. if(idx==6) {
  31. $(tr).children().each((tdid, td)=>{
  32. if (hyidx !== null && tdid === hyidx+1) {
  33. hy = $(td).text()
  34. } else if($(td).text()=='行业') {hyidx = tdid;}
  35. })
  36. }
  37. })
  38. return hy;
  39. }
  40. // 获取经营范围信息
  41. function getjyinfo() {
  42. var jy = '';
  43. let jyidx = null;
  44. $('.index_tableBox__ZadJW tr').each((idx, tr)=>{
  45. if(idx==10) {
  46. $(tr).children().each((tdid, td)=>{
  47. if (jyidx !== null && tdid === jyidx+1) {
  48. jy = $(td).text()
  49. } else if($(td).text()=='经营范围') {jyidx = tdid;}
  50. })
  51. }
  52. })
  53. return jy;
  54. }
  55. // 获取县区名
  56. function getcounty() {
  57. var info;
  58. var result = '';
  59. var loc = $('.index_detail-address__ZmaTI').html();
  60. var reg = /.+?(省|市|自治区|自治州|县|区)/g
  61. if (loc) {
  62. info = loc.match(reg)
  63. }
  64. info.forEach((it, idx)=>{
  65. if(it.includes('县')) result = it
  66. else if(it.includes('区')) result = it
  67. else if(it.includes('市')) result = it
  68. })
  69. return result;
  70. }
  71.  
  72. // 获取联系方式
  73. function getrls() {
  74. var man = $('.index_link-click__NmHxP').html();
  75. var tel = $('.index_detail-tel__fgpsE').html();
  76. return '('+man+'){法人}['+tel+']'
  77. }
  78.  
  79. // 获取全部信息
  80. function getinfo() {
  81. var com = $('.index_company-name__LqKlo').html();
  82. var loc = $('.index_detail-address__ZmaTI').html();
  83. var dec = $('.introduceRich_expand-item__Vuo_n').text()
  84. try {
  85. dec = dec.match(/基本信息(\S*)企业注册(不可用)资本/)[1];
  86. } catch (e) {
  87. console.log(e)
  88. }
  89. var rls = getrls();
  90. var hyi = gethyinfo();
  91. var cou = getcounty();
  92. var jyi = getjyinfo();
  93. var obj = {com, loc, cou, hyi, rls, dec, jyi};
  94. return obj;
  95. }
  96. // 缓存一次保障效率
  97. var info = getinfo()
  98.  
  99. //setTimeout(console.info(Object.values(info).join('\n')), 1000)
  100.  
  101. // 保存进剪切板需异步操作
  102. async function copyinfo() {
  103. try {
  104. await navigator.clipboard.writeText(Object.values(info).join('\t')+"\n");
  105.  
  106. $("#x-copy").html("已复制");
  107. $("#x-copy").css("background-color", "#00FF6677")
  108.  
  109. setTimeout(()=>{
  110. $("#x-copy").html("复制信息");
  111. $("#x-copy").css("background-color", "#0066FF77")
  112. }, 1000)
  113. console.log('Infos copied to clipboard');
  114. } catch (err) {
  115. console.error('Failed to copy: ', err);
  116. }
  117. }
  118. // 挂载到窗体
  119. window.copyinfo = copyinfo;
  120.  
  121. // 多页支持
  122. function mulinfo() {
  123. let cominfo = {}
  124. let locst = localStorage.getItem('cominfo')
  125. if (locst) {
  126. cominfo = JSON.parse(locst)
  127. }
  128. cominfo[info.com] = Object.values(info).join('\t')+"\n";
  129. localStorage.setItem('cominfo', JSON.stringify(cominfo))
  130. return Object.values(cominfo).length
  131. }
  132.  
  133. // 执行保存
  134. let listnum = mulinfo();
  135. // 清空
  136. function reload() {
  137. localStorage.removeItem('cominfo');
  138. $("#x-copylist").html(`复制(0)条`);
  139. listnum = 0
  140. }
  141. // 挂载到窗体
  142. window.reload = reload;
  143.  
  144.  
  145. // 保存进剪切板需异步操作
  146. async function copylist() {
  147. try {
  148. if (listnum>0) {
  149. let locst = localStorage.getItem('cominfo');
  150. let infolist = Object.values(JSON.parse(locst));
  151.  
  152. await navigator.clipboard.writeText(infolist.join(''));
  153. console.info(infolist.join('\n'))
  154. $("#x-copylist").html("已复制");
  155. $("#x-copylist").css("background-color", "#00FF6677")
  156.  
  157. setTimeout(()=>{
  158. $("#x-copylist").html(`复制(${infolist.length})条`);
  159. $("#x-copylist").css("background-color", "#0066FF77")
  160. }, 1000)
  161. console.log('Infos copied to clipboard');
  162. } else {
  163. console.info("没有要复制的数据")
  164. }
  165. } catch (err) {
  166. console.error('Failed to copy: ', err);
  167. }
  168. }
  169. // 挂载到窗体
  170. window.copylist = copylist;
  171.  
  172. var infodom =
  173. `<textarea id="x-copyinfo"
  174. style="position: fixed;
  175. top: 300px;
  176. left: 20px;
  177. width: 200px;
  178. height: 120px;
  179. padding: 10px;
  180. background-color: #CCCCCC77;">${Object.values(info).join('\n')}</textarea>`;
  181.  
  182. var btn =
  183. `<div id="x-copy"
  184. style="position: fixed;
  185. top: 420px;
  186. left: 100px;
  187. width:120px;
  188. height: 40px;
  189. text-align: center;
  190. border-radius: 5px;
  191. border: 2px #FFF dotted;
  192. cursor: pointer;
  193. padding: 10px;
  194. background-color: #0066FF77;"
  195. onclick="copyinfo()">复制信息</div>`;
  196.  
  197. var mulbtn =
  198. `<div id="x-copylist"
  199. style="position: fixed;
  200. top: 460px;
  201. left: 100px;
  202. width:120px;
  203. height: 40px;
  204. text-align: center;
  205. border-radius: 5px;
  206. border: 2px #FFF dotted;
  207. cursor: pointer;
  208. padding: 10px;
  209. background-color: #0066FF77;"
  210. onclick="copylist()">复制(${listnum})条</div>`;
  211. var rebtn =
  212. `<div id="x-reload"
  213. style="position: fixed;
  214. top: 460px;
  215. left: 20px;
  216. width:60px;
  217. text-align: center;
  218. border-radius: 5px;
  219. border: 2px #FFF dotted;
  220. cursor: pointer;
  221. padding: 10px;
  222. background-color: #0066FF77;"
  223. onclick="reload()">清空</div>`;
  224.  
  225. $('body').append(infodom);
  226. $('body').append(btn);
  227. $('body').append(mulbtn);
  228. $('body').append(rebtn);
  229.  
  230. }, 1000);
  231.  
  232.  
  233. // Your code here...
  234. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址