微博超话图片下载

提供超话内原图下载,优化超话浏览体验

  1. // ==UserScript==
  2. // @name 微博超话图片下载
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1
  5. // @description 提供超话内原图下载,优化超话浏览体验
  6. // @author 乃木流架
  7. // @match https://weibo.com/p/*
  8. // @match https://weibo.com/u/*
  9. // @match https://d.weibo.com/*
  10. // @match https://weibo.com/*
  11. // @icon https://i.jpg.dog/26e8e3a48d8a079e3bca9bae1a96434b.png
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.7.3/sweetalert2.all.js
  14. // @grant GM_addStyle
  15. // @grant GM_setValue
  16. // @grant GM_getValue
  17. // @grant GM_download
  18. // @run-at document-start
  19. // @license MIT
  20. // ==/UserScript==
  21.  
  22. (function () {
  23. ("use strict");
  24. console.log("🏳️‍🌈[微博超话图片下载]脚本开始执行");
  25.  
  26. //自定义用户主页背景图片
  27. //图床:https://jpg.dog/
  28. // const urlNew = "https://i.jpg.dog/f5651b662ec09801fdd4a54285038ee1.jpeg";
  29. const urlNew = "https://tva1.sinaimg.cn/mw690/005Ant5dgy1hjzgdh531cj335s1s0kjl.jpg";
  30.  
  31. //默认主页背景图片
  32. const urlDefault1 =
  33. "https://ww1.sinaimg.cn/mw2000/70ace9b7ly1ggzusnypoej20yi0yiaop.jpg";
  34. const urlDefault2 =
  35. "https://wx1.sinaimg.cn/mw2000/001WLsZ7ly1gs69906b4pj60u00u0wiu02.jpg";
  36. const urlDefault3 =
  37. "https://wx1.sinaimg.cn/mw2000/007v6V7hly1h9i7kq8c3pj30u00u0wg7.jpg";
  38.  
  39. /**
  40. * @desc 属性改变监听,属性被set时出发watch的方法,类似vue的watch
  41. * @author Jason
  42. * @study https://www.jianshu.com/p/00502d10ea95
  43. * @data 2018-04-27
  44. * @constructor
  45. * @param {object} opts - 构造参数. @default {data:{},watch:{}};
  46. * @argument {object} data - 要绑定的属性
  47. * @argument {object} watch - 要监听的属性的回调
  48. * watch @callback (newVal,oldVal) - 新值与旧值
  49. */
  50. class watcher {
  51. constructor(opts) {
  52. this.$data = this.getBaseType(opts.data) === "Object" ? opts.data : {};
  53. this.$watch = this.getBaseType(opts.watch) === "Object" ? opts.watch : {};
  54. for (let key in opts.data) {
  55. this.setData(key);
  56. }
  57. }
  58.  
  59. getBaseType(target) {
  60. const typeStr = Object.prototype.toString.apply(target);
  61.  
  62. return typeStr.slice(8, -1);
  63. }
  64.  
  65. setData(_key) {
  66. Object.defineProperty(this, _key, {
  67. get: function () {
  68. return this.$data[_key];
  69. },
  70. set: function (val) {
  71. const oldVal = this.$data[_key];
  72. if (oldVal === val) return val;
  73. this.$data[_key] = val;
  74. this.$watch[_key] &&
  75. typeof this.$watch[_key] === "function" &&
  76. this.$watch[_key].call(this, val, oldVal);
  77. return val;
  78. },
  79. });
  80. }
  81. }
  82.  
  83. const Toast = Swal.mixin({
  84. toast: true,
  85. position: "bottom-end",
  86. showConfirmButton: false,
  87. timer: 3000,
  88. timerProgressBar: true,
  89. didOpen: (toast) => {
  90. toast.addEventListener("mouseenter", Swal.stopTimer);
  91. toast.addEventListener("mouseleave", Swal.resumeTimer);
  92. },
  93. });
  94.  
  95. const picImpl = "https://weibo.com/ajax/statuses/show?id=";
  96. const chaohuaImpl =
  97. "https://weibo.com/ajax/profile/topicContent?tabid=231093_-_chaohua";
  98. let length = 15;
  99. let wm = new watcher({
  100. data: {
  101. len: length,
  102. },
  103. watch: {
  104. len(newVal, oldVal) {
  105. // console.log("length: ", length);
  106. console.log("🔢新微博条数:" + newVal);
  107. console.log("🔢旧微博条数:" + oldVal);
  108. if (newVal > length) {
  109. let faces = document.getElementsByClassName("WB_info");
  110. let i = length;
  111. length = faces.length;
  112. if (/d.weibo.com/.test(currLink)) {
  113. while (i < length) {
  114. // console.log("处理链接");
  115. let btn = initBtn();
  116. let at = faces[i].nextElementSibling.children[0];
  117. // console.log(at);
  118. at.href = at.href + "?page_source=hot";
  119. // console.log(at);
  120. faces[i].appendChild(btn);
  121. // console.log(i);
  122. // console.log(faces[i]);
  123. handleBtn(btn);
  124. i++;
  125. }
  126. } else {
  127. while (i < length) {
  128. let btn = initBtn();
  129. faces[i].appendChild(btn);
  130. // console.log(i);
  131. // console.log(faces[i]);
  132. handleBtn(btn);
  133. i++;
  134. }
  135. }
  136. }
  137. },
  138. },
  139. });
  140.  
  141. function sendAjax(type, url, flag) {
  142. let xhr = new XMLHttpRequest();
  143. xhr.open(type, url, flag);
  144. xhr.send();
  145. let res = xhr.responseText;
  146. // console.log(xhr.responseText);
  147. // return JSON.parse(res);
  148. return res;
  149. }
  150.  
  151. function initBtn() {
  152. let div = document.createElement("div");
  153. let img = document.createElement("img");
  154. let a = document.createElement("a");
  155. // img.src = "https://i.jpg.dog/72dbffd3545cb15b148682beaf0fb64a.png";
  156. // img.src = "https://i.jpg.dog/d5380c9048e6ee303f188da9ec574399.png";
  157. img.src =
  158. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEMAAABDCAYAAADHyrhzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFMElEQVR4nO2baYgcRRTHKzGJqFlFvDDRL16RCB6sG3f7vdnxQ+KBB3gEL4R8cVFUZN0se8x7U4giqIj4TZB4bEAJKIpCUBA0+SCaLwoKUYOKmCBoNEYYp6vGWFJzrLs7PTO93V3dk539Q8F8merXv36vjveqhFhWd8iMDp5kZP7MssQLygXvwpL01hm56VSxlGWkWKmkd6UmHNUEM4rhc0VwRDOaoKYYfM34tWZ8WxE+WSngZgtOHM8AKgxbai+Ph1u9eNhmASmCjxTltplxr08cDzITm0/ThAXNeDAugJZgCEua4BWfvA2iG2XGvT7F8JRi+NMVhAAoxzTjrq6C4jPcogl/SgtCcwihVgQvGplfmxkEMzlwhmJ4PysITY3we81DA6mD0NO5TZrhh8wBNIUOVDThhBFiRSogfILb69Of6eL2upH5VU5B6AI8XB+4sn7ZMGHznrP1iWZ4xI1r4zFFUHbU924z0r86URCK8G43HgHflWT+PCM3rtEMO914CMwkNoZo9oYUoXJkKP8PHK5wGDIyNggziadrgh+dGcmwvfEsn4YvdvUc69V2jxMLhmZ4xx2I9GDUgMAvdpccCYTPuTvcgkgXRr3tWDQII/tPdhse2cBQjP9qxvyiYGjGYgpfKQvPsOPHvvBeMbblFEXw21KFYVul4F0X0itge1pGZQVDEe7t7BVCrKjt/pY2jCoQiZe394pCbjhNgzKFwfBspxB5uVdgaMJDNlfbBgYe7BkYtdYfCMKXQ5emb0zGMCg33sIrvAd7DYbd4gfCUIwv9RoMO260gvFxz8FgNIElTU14qBdh6Gnv6qbFlmL4pxdhVDh3U/MulTP4Kl0Aw6Y058OYuuacnoVRxAfmwShJb12vwrBLivmeMe719SoMVfTuWzBmiJX1LFDEugfuVoSfpg7DZuMI3lKMf0SF4ZN3a9A643CkDglHZ6dnhsm0YNjDK3bgr/3X2xBjNoRmGBTly9p5Ggbn9mMLv65hVEEsKB0qhl+j2G+m8KwmGJrwtWhk4dWAviZcwQgCYYvhUWxXhL83gYib7lOEL4hIQBYHIwhEheHGqKcCWqb/NA8NRIXRALKwpqkJxpKCoRj22GT1fBC56+MUrRXBE4EwzNatJ7Q7kugGSDgYLkDYVinAtYEwrOw0FafzBhAROmQ6w0g6NObYedQ8esOJopV8htviwlich7SH4cojQpUajdy4JqkCUjggrWE4BtE+RBpSBM8n8bBwIRMMw1VozDaCb9tmxhsy07lzkzxW1N5DmmG49oiaTbltIqxUwvnQlkAIxubCSAOEPcBrh4PQMErTg+sV419JA1n4HCOHzp79Pe71OQ2Nhh1FvCc0iIY04+NJGtHKQ1opcY9ohGCUw25G5ldpwi9cAOkMwoFHEJRtoUxElW/jmPBomh7iwiPqbUTElSp6dzkwLBCIQxC7YoNoSDE+7RqIi9Coh8dnC2eoWDL2EAvjDjdA4BPN8Gb1RkDS/RPuj3zcsfOACjMugDhphPv/LuTOF65kbOWN4JnMX7Sjt+G+wHSeC+kCPtS9d05gZyNRnJoUDV+lCQ90jzdAWRM8JrKSkfm1ivA5e2kuUxCMH9o1kegGKYLLFMEHqYMgPOAT3im6UdomlQnedX51i/ArRXCvzduKbldpenC9jV/N+GWCY8IRO7VX78andTsxaZXl4EV2X6AJ3tCM34QeXwh+roYewZSt2jm/jZiFzEj/al/iJTYHWSG8uXr/rYj322S0/er2elamt5eXtSwxV/8B8CHKT9TokA8AAAAASUVORK5CYII=";
  159. img.setAttribute(
  160. "style",
  161. "width:12px;height:12px;margin-top:5px;margin-right:2px;"
  162. );
  163. a.innerHTML = "图片下载";
  164. a.setAttribute(
  165. "style",
  166. "padding:0;font-size: 12px;margin-top:1px;color:#333333;margin-top: 3px;"
  167. );
  168. div.appendChild(img);
  169. div.appendChild(a);
  170. div.setAttribute("class", "nogiruka-button");
  171. div.setAttribute(
  172. "style",
  173. "display: inline-flex;position:absolute;box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1);border:1px solid #d9d9d9;height:21px;width:80px;background-color:#ffffff;font-color:#333333;font-size: 12px;text-align: center;border-radius: 2px;cursor: pointer;margin-left:5px;margin-top:-2px;justify-content: center;"
  174. );
  175. return div;
  176. }
  177.  
  178. let firstLength = 100;
  179. function addBtn() {
  180. let faces = document.getElementsByClassName("WB_info");
  181. let i = 0;
  182. length = faces.length;
  183. if (length < firstLength) {
  184. firstLength = length;
  185. console.log("🔢初始微博条数: " + firstLength);
  186. }
  187.  
  188. while (i < length) {
  189. let btn = initBtn();
  190. faces[i].appendChild(btn);
  191. // console.log(i);
  192. // console.log(faces[i]);
  193. handleBtn(btn);
  194. i++;
  195. }
  196. }
  197.  
  198. function handleBtn(btn) {
  199. btn.addEventListener("click", function (e) {
  200. let info = e.target.parentNode.parentNode;
  201. let from = info.nextElementSibling;
  202. let href = from.firstElementChild.href;
  203. // console.log(info);
  204. // console.log(from);
  205. // console.log(href);
  206. if (/page_source=hot/.test(href) && /d.weibo.com/.test(currLink)) {
  207. window.open(href);
  208. setTimeout(() => {
  209. Toast.fire({
  210. timer: 3000,
  211. icon: "success",
  212. title:
  213. "🌈微博用户: " +
  214. GM_getValue("use") +
  215. '\n📝微博文案: <div id="tex">' +
  216. GM_getValue("tex") +
  217. "</div>💝开始下载图片\n💖图片下载完毕\n📦共计 " +
  218. GM_getValue("picn") +
  219. " 张图片",
  220. });
  221. }, 2000);
  222. // setTimeout(() => {
  223. // // 获取整个页面元素
  224. // var page = document.documentElement;
  225. // // 创建键盘事件对象
  226. // var event = new KeyboardEvent("keydown", { keyCode: 27 });
  227. // // 触发键盘事件
  228. // page.dispatchEvent(event);
  229. // }, 4000);
  230. // return;
  231. } else {
  232. handleUrl(href, false);
  233. }
  234. });
  235. }
  236.  
  237. function handleUrl(href, flag) {
  238. let h = href.split("?")[0];
  239. let mblogid = h.split("/")[h.split("/").length - 1];
  240. let url = picImpl + mblogid;
  241. // console.log(mblogid);
  242. // console.log(url);
  243. let response = JSON.parse(sendAjax("GET", url, flag));
  244. // console.log(response);
  245. handlePic(response);
  246. }
  247.  
  248. let tao = {
  249. us: "",
  250. te: "",
  251. };
  252. function handlePic(response) {
  253. const picInfos = response.pic_infos;
  254. const mblogid = response.mblogid;
  255. // console.log(picInfos);
  256. const picNum = response.pic_num;
  257. GM_setValue("picn", picNum);
  258. const userName = response.user.screen_name;
  259. const text = response.text_raw;
  260. tao.us = userName;
  261. tao.te = text;
  262. GM_setValue("use", userName);
  263. GM_setValue("tex", text);
  264. console.log("🌈微博用户:" + userName + "\n📝微博文案:\n" + text);
  265. // Toast.fire({
  266. // icon: "info",
  267. // title: "🌈微博用户:" + userName + "\n📝微博文案:\n" + text,
  268. // });
  269. let downloadList = [];
  270. if (picInfos) {
  271. // Toast.fire({
  272. // timer: 10000,
  273. // icon: "success",
  274. // title:
  275. // "🌈微博用户:" +
  276. // userName +
  277. // "\n📝微博文案:\n" +
  278. // text +
  279. // "\n💝开始下载图片",
  280. // });
  281. console.log("💝开始下载图片");
  282. let index = 0;
  283. for (const [id, pic] of Object.entries(picInfos)) {
  284. index += 1;
  285. let largePicUrl = pic.largest.url;
  286. let picName = largePicUrl
  287. .split("/")
  288. [largePicUrl.split("/").length - 1].split("?")[0];
  289. let ext = picName.split(".")[1];
  290. let dlName = userName + "-" + mblogid + "-" + index + "." + ext;
  291. downloadList.push({
  292. index: index,
  293. picNum: picNum,
  294. url: largePicUrl,
  295. name: dlName,
  296. headerFlag: true,
  297. });
  298. }
  299. // console.log(downloadList);
  300. handleDownloadList(downloadList);
  301. }
  302. }
  303.  
  304. function handleDownloadList(downloadList) {
  305. for (const item of downloadList) {
  306. downloadWrapper(
  307. item.index,
  308. item.picNum,
  309. item.url,
  310. item.name,
  311. item.headerFlag
  312. );
  313. }
  314. }
  315.  
  316. const pro = {
  317. a: "🌚", //0-25
  318. b: "🌘", //25-50
  319. c: "🌓", //50
  320. d: "🌒", //50-75
  321. e: "🌝", //100
  322. };
  323. function downloadWrapper(index, picNum, url, name, headerFlag) {
  324. let textContent = name + " [0%]";
  325. let percent = 0;
  326. const download = GM_download({
  327. url,
  328. name,
  329. headers: headerFlag
  330. ? {
  331. Referer: "https://weibo.com/",
  332. Origin: "https://weibo.com/",
  333. }
  334. : null,
  335. // saveAs: false,
  336. onprogress: (e) => {
  337. // e = { int done, finalUrl, bool lengthComputable, int loaded, int position, int readyState, response, str responseHeaders, responseText, responseXML, int status, statusText, int total, int totalSize }
  338. percent = (e.done / e.total) * 100;
  339. percent = percent.toFixed(0);
  340. textContent = name + " [" + percent + "%]";
  341. if (percent < 25) {
  342. console.log(pro.a + textContent);
  343. } else if (percent >= 25 && percent < 50) {
  344. console.log(pro.b + textContent);
  345. } else if (percent >= 50 && percent < 75) {
  346. console.log(pro.c + textContent);
  347. } else if (percent >= 75 && percent < 100) {
  348. console.log(pro.d + textContent);
  349. } else {
  350. console.log(pro.e + textContent);
  351. }
  352.  
  353. // console.log(textContent);
  354. },
  355. onload: () => {
  356. // console.log("💖" + name + " 下载完毕");
  357. if (
  358. /page_source=hot/.test(currLink) &&
  359. !/root_comment_id/.test(currLink) &&
  360. /weibo.com/.test(currLink) &&
  361. index == picNum
  362. ) {
  363. console.log("💖图片下载完毕\n" + "📦共计 " + picNum + " 张图片");
  364. window.close();
  365. } else if (index == picNum) {
  366. console.log("💖图片下载完毕\n" + "📦共计 " + picNum + " 张图片");
  367. Toast.fire({
  368. timer: 3000,
  369. icon: "success",
  370. title:
  371. "🌈微博用户: " +
  372. tao.us +
  373. '\n📝微博文案: <div id="tex">' +
  374. tao.te +
  375. "</div>💝开始下载图片\n💖图片下载完毕\n📦共计 " +
  376. picNum +
  377. " 张图片",
  378. });
  379. }
  380. },
  381. onerror: (e) => {
  382. console.log(e);
  383. },
  384. ontimeout: (e) => {
  385. console.log(e);
  386. },
  387. });
  388. }
  389.  
  390. function handleQ() {
  391. //搜索处理
  392. if (document.getElementsByClassName("username")[0]) {
  393. let username = document.getElementsByClassName("username")[0].innerText;
  394. let input = document.getElementsByClassName("W_input")[0];
  395. let q = username + "超话 ";
  396. let ph = document.getElementsByClassName("placeholder")[0];
  397. if (ph != null) {
  398. ph.remove();
  399. }
  400. // console.log(input.value);
  401. if (input.value != q) {
  402. input.value = q;
  403. }
  404. }
  405. }
  406.  
  407. function chaohuaBtn(div, imgdiv) {
  408. //超话按钮添加
  409. //处理超话按钮位置
  410. let tab = document.getElementsByClassName("wbpro-tab2")[0];
  411. tab.childNodes[5].remove();
  412. tab.childNodes[5].remove();
  413.  
  414. //生成超话图标
  415. let img = document.createElement("img");
  416. let p = document.createElement("p");
  417. p.textContent = "全部超话";
  418. p.style.display = "none";
  419. img.className = "icon-link wbpro-textcut nogiruka";
  420. img.setAttribute(
  421. "style",
  422. "padding:5px;width: 22px;height: 22px;margin-top: 6px;color: black;cursor: pointer;"
  423. );
  424. img.src =
  425. "https://h5.sinaimg.cn/upload/100/959/2020/05/09/timeline_card_small_super_default.png";
  426. imgdiv.className = "woo-box-item-inlineBlock";
  427. imgdiv.appendChild(img);
  428. imgdiv.appendChild(p);
  429. //生成我的超话
  430. let divin = document.createElement("div");
  431. let d = document.createElement("div");
  432. div.className = "woo-box-item-inlineBlock";
  433. divin.className = "woo-box-flex woo-box-alignCenter woo-box-justifyCenter";
  434. d.className = "wbpro-textcut";
  435. d.innerHTML = "我的超话";
  436. divin.appendChild(d);
  437. div.appendChild(divin);
  438. //整合按钮
  439. tab.children[3].insertAdjacentElement("beforebegin", imgdiv);
  440. tab.children[3].insertAdjacentElement("beforebegin", div);
  441. }
  442.  
  443. function handleChaohua(again = true) {
  444. // console.log("handleChaohua...");
  445. let tab = document.getElementsByClassName("wbpro-tab2")[0];
  446. let div = document.createElement("div");
  447. let imgdiv = document.createElement("imgdiv");
  448.  
  449. if (again) {
  450. chaohuaBtn(div, imgdiv);
  451. } else {
  452. div = tab.children[3];
  453. imgdiv = tab.children[4];
  454. }
  455.  
  456. //获取超话列表
  457. let data = JSON.parse(sendAjax("GET", chaohuaImpl, false)).data;
  458. // console.log(data);
  459. let res = data.list;
  460. // console.log(data);
  461. let length = res.length;
  462. let chaohuaList = [];
  463. if (res) {
  464. let index = 0;
  465. for (const [id, l] of Object.entries(res)) {
  466. index += 1;
  467. let link = l.link;
  468. let pic = l.pic;
  469. let topic_name = l.topic_name;
  470. let content1 = l.content1;
  471. let content2 = l.content2;
  472. chaohuaList.push({
  473. index: index,
  474. link: link,
  475. pic: pic,
  476. topic_name: topic_name,
  477. content1: content1,
  478. content2: content2,
  479. });
  480. }
  481. // console.log(chaohuaList);
  482. }
  483.  
  484. //为我的超话和超话图标绑定点击事件
  485. imgdiv.addEventListener("click", function () {
  486. window.location.href = chaohuaAll;
  487. });
  488. div.addEventListener("click", function () {
  489. console.log("💝开始处理超话信息");
  490. console.log("🔢超话条数:" + length);
  491. //点击高亮
  492. for (let index = 0; index < tab.children.length; index++) {
  493. tab.children[index].className = "woo-box-item-inlineBlock";
  494. }
  495. div.className = "woo-box-item-inlineBlock cur";
  496. //
  497. wrapper = document.getElementsByClassName(
  498. "vue-recycle-scroller__item-wrapper"
  499. )[0];
  500. wrapper.firstElementChild.insertAdjacentElement(
  501. "beforebegin",
  502. wrapperDiv
  503. );
  504. // console.log(e);
  505. while (wrapper.hasChildNodes()) {
  506. //当wrapper下还存在子节点时 循环继续
  507. wrapper.removeChild(wrapper.firstChild);
  508. }
  509. // console.log("wrapper: ", wrapper);
  510. handleChaohuaList(chaohuaList, length);
  511. });
  512. }
  513.  
  514. function handleChaohuaList(chaohuaList, length) {
  515. // console.log("handleChaohuaList...");
  516.  
  517. for (const item of chaohuaList) {
  518. // console.log("处理超话列表。。。");
  519. // console.log(item);
  520. chaohuaWrapper(
  521. item.index,
  522. item.link,
  523. item.pic,
  524. item.topic_name,
  525. item.content1,
  526. item.content2
  527. );
  528. }
  529. // console.log("wrapperDiv.length: " + wrapperDiv.children.length);
  530. // 添加查看全部超话按钮
  531. if (wrapperDiv.children.length == length) {
  532. // console.log("添加查看全部超话按钮。。。");
  533. let all = document.createElement("div");
  534. let bt = document.createElement("a");
  535. all.className = "W_pages";
  536. all.setAttribute(
  537. "style",
  538. "background-color: white;display: grid;padding: 20px;transform: translateY(" +
  539. length * 92 +
  540. "px);"
  541. );
  542. // a.className = "page next S_txt1 S_line1";
  543. bt.innerHTML = "查看全部超话";
  544. // bt.className = "nogiruka";
  545. // bt.className = "page next S_txt1 S_line1";
  546. bt.href = chaohuaAll;
  547.  
  548. bt.setAttribute(
  549. "style",
  550. "padding: 4px 0;text-align: center;font-weight: 400;background-color: transparent;cursor: pointer;font-size: 15px;display: block;border: 1px solid transparent;color:#fa7d3c"
  551. );
  552. all.appendChild(bt);
  553. wrapperDiv.appendChild(all);
  554. console.log("💖超话信息处理完毕");
  555. // console.log(wrapperDiv);
  556. } else {
  557. // alert("❌出错了,请刷新");
  558. // location.reload();
  559. // return;
  560. handleChaohua((again = false));
  561. console.log("💖超话信息处理完毕");
  562. }
  563. wrapper.appendChild(wrapperDiv);
  564. }
  565.  
  566. let autoplaySigns = localStorage.getItem("autoplaySigns");
  567. if (autoplaySigns != null) {
  568. let userId = autoplaySigns.split('"')[1];
  569. if (userId != GM_getValue("userId")) {
  570. GM_setValue("userId", userId);
  571. }
  572. // GM_setValue("userId", userId);
  573. }
  574.  
  575. console.log("🆔登录(不可用)用户ID为:" + GM_getValue("userId"));
  576. const chaohuaAll =
  577. "https://weibo.com/u/page/follow/" +
  578. GM_getValue("userId") +
  579. "/231093_-_chaohua";
  580. let wrapper = "";
  581. let wrapperDiv = document.createElement("div");
  582. wrapperDiv.className = "wrapperDiv";
  583. function chaohuaWrapper(index, link, pic, topic_name, content1, content2) {
  584. //
  585. // console.log("chaohuaWrapper...");
  586. let tr = (index - 1) * 92;
  587. // console.log(index);
  588. // console.log(tr);
  589. let st = "background-color: white;transform: translateY(" + tr + "px)";
  590. // console.log(st);
  591. let view = document.createElement("div");
  592. view.className = "vue-recycle-scroller__item-view";
  593. view.setAttribute("style", st);
  594. view.innerHTML =
  595. '<div data-index="0" data-active="true" class="wbpro-scroller-item"><div class="woo-box-flex TopicFeedCard_topicFeedCard_159d4"><div class="woo-box-flex woo-box-alignCenter TopicFeedCard_item_1Ikoi"><a class="ALink_none_1w6rm TopicFeedCard_left_EgdGf" href="' +
  596. link +
  597. "/super_index" +
  598. '" target="_blank"><div class="woo-picture-main woo-picture-square woo-picture-hover TopicFeedCard_pic_1ilsA" style="width: 3.125rem;"><!----><img alt="等比图" src="' +
  599. pic +
  600. '" class="woo-picture-img"><div class="woo-picture-cover"></div><div class="woo-picture-hoverMask"></div><!----></div><div class="woo-box-item-flex TopicFeedCard_con_294Gq TopicFeedCard_f12_avvOy" style="align-self: center;"><div class="TopicFeedCard_cla_1pQ6t TopicFeedCard_fb_1aJkn TopicFeedCard_cut_3akoX">' +
  601. topic_name +
  602. '</div><div class="TopicFeedCard_clb_3j52M TopicFeedCard_cut_3akoX"> ' +
  603. content1 +
  604. ' </div><div class="TopicFeedCard_clb_3j52M">' +
  605. content2 +
  606. '</div></div></a><div class="TopicFeedCard_right_1ygKg"><button class="woo-button-main woo-button-line woo-button-default woo-button-s woo-button-round FollowBtn_s_3J5Ve"><span class="woo-button-wrap"><!----><!----><!----><span class="woo-button-content"> 已关注 </span></span></button></div></div></div></div>';
  607. let view1 = view;
  608. wrapperDiv.appendChild(view1);
  609. // while (view.hasChildNodes()) {
  610. // //当table下还存在子节点时 循环继续
  611. // view.removeChild(view.firstChild);
  612. // }
  613. // console.log(wrapper);
  614. }
  615.  
  616. function handleBack() {
  617. let backMain = document.getElementsByClassName(
  618. "woo-picture-main ProfileHeader_pic_2Coeq"
  619. )[0];
  620. let back = {};
  621. if (backMain !== undefined) {
  622. back = backMain.getElementsByTagName("img")[0];
  623. }
  624. if (backMain != null && back != null) {
  625. let url = back.src;
  626. // console.log(url != null);
  627. // console.log(url == urlDefault1);
  628. // console.log(url);
  629. // console.log(urlDefault);
  630. if (url != null) {
  631. if (url == urlDefault1 || url == urlDefault2 || url == urlDefault3) {
  632. back.src = urlNew;
  633. }
  634. }
  635. }
  636. }
  637.  
  638. let ba = setInterval(() => {
  639. //更换用户主页背景图片
  640. handleBack();
  641. // console.log("更改用户主页背景图片。。。");
  642. }, 50);
  643. let go1 = true;
  644. let go2 = true;
  645. let tabgo = true;
  646. let currLink = window.location.href;
  647. let jumpLink = "";
  648.  
  649. //全局循环器
  650. setInterval(() => {
  651. //
  652. // console.log("⏳全局循环");
  653. let backMain = document.getElementsByClassName(
  654. "woo-picture-main ProfileHeader_pic_2Coeq"
  655. )[0];
  656. let back = {};
  657. if (backMain !== undefined) {
  658. back = backMain.getElementsByTagName("img")[0];
  659. }
  660. jumpLink = window.location.href;
  661. // console.log("currLink: " + currLink);
  662. // console.log("jumpLink: " + jumpLink);
  663. // console.log("window.location.href: " + window.location.href);
  664. //检测链接变化
  665. if (currLink != jumpLink) {
  666. console.log("🔄链接跳转\n🔗" + currLink + "\n👇\n🔗" + jumpLink + "\n");
  667. // [currLink, jumpLink] = [jumpLink, currLink];
  668. // console.log("currLink: " + currLink);
  669. // console.log("jumpLink: " + jumpLink);
  670. currLink = jumpLink;
  671. //监听网页链接变化,刷新页面
  672. setTimeout(() => {
  673. if (/d.weibo.com/.test(jumpLink)) {
  674. addBtn();
  675. }
  676. }, 1000);
  677.  
  678. if (/weibo.com\/u/.test(jumpLink)) {
  679. console.log("✅进入用户主页");
  680. }
  681. }
  682. //设置超话页面所有链接为新标签页打开
  683. // if (/weibo.com\/p/.test(currLink)) {
  684. // // console.log($("a"));
  685. // $("a").attr("target", "_blank");
  686. // }
  687.  
  688. if (/weibo.com\/u/.test(jumpLink) && backMain != null) {
  689. if (
  690. back.src == urlDefault1 ||
  691. back.src == urlDefault2 ||
  692. back.src == urlDefault3
  693. ) {
  694. // $(".woo-picture-main.ProfileHeader_pic_2Coeq").val();
  695. // location.reload();
  696. handleBack();
  697. }
  698. }
  699.  
  700. //伪超话内搜索
  701. handleQ();
  702.  
  703. //去除扫描二维码进入手机超话
  704. let qr = document.getElementById("Pl_Core_PicText__263");
  705. if (qr) {
  706. qr.remove();
  707. }
  708. //去除超话内微博聊天
  709. let chat = document.getElementById("WB_webchat");
  710. if (chat) {
  711. chat.remove();
  712. }
  713.  
  714. //清除背景图片监视
  715. if (go1) {
  716. if (!backMain) {
  717. go1 = false;
  718. clearInterval(ba);
  719. console.log("❎不是用户主页");
  720. }
  721. if (/weibo.com\/u/.test(currLink) && backMain != null) {
  722. if (
  723. back.src != urlDefault1 &&
  724. back.src != urlDefault2 &&
  725. back.src != urlDefault3
  726. ) {
  727. go1 = false;
  728. clearInterval(ba);
  729. console.log("✅背景图片已修改");
  730. }
  731. }
  732. }
  733.  
  734. //我的超话按钮高亮清除
  735. let tab = document.getElementsByClassName("wbpro-tab2")[0];
  736. if (tab != null && tabgo) {
  737. tabgo = false;
  738. for (let index = 0; index < tab.children.length; index++) {
  739. tab.children[index].addEventListener("click", function () {
  740. // console.log("🌟", tab.children[index].innerText, "按钮已高亮");
  741. tab.children[3].className = "woo-box-item-inlineBlock";
  742. });
  743. }
  744. }
  745.  
  746. //超话按钮生成
  747. let home = document.getElementsByClassName("Search_outer_3k7Aq")[0];
  748. let chaohuaimg = document.getElementsByClassName(
  749. "icon-link wbpro-textcut nogiruka"
  750. )[0];
  751. if (home != null) {
  752. if (chaohuaimg != null) {
  753. return;
  754. } else {
  755. console.log("🌼生成超话按钮");
  756. handleChaohua();
  757. }
  758. }
  759.  
  760. //翻页监视
  761. let nextPage = document.getElementsByClassName(
  762. "page next S_txt1 S_line1"
  763. )[0];
  764. // console.log(nextPage);
  765. if (nextPage != null && go2) {
  766. go2 = false;
  767. hr = nextPage.href;
  768. console.log("🚌下一页出现,地址为:" + hr);
  769. nextPage.addEventListener("click", function () {
  770. window.location.href = hr;
  771. });
  772. }
  773.  
  774. //微博条数监控
  775. let temp = document.getElementsByClassName("WB_info").length;
  776. if (temp != length && temp > length) {
  777. wm.len = temp;
  778. }
  779. }, 1000);
  780.  
  781. function hot(currLink) {
  782. // console.log(currLink);
  783. // console.log("page_source=hot...");
  784. if (/page_source=hot/.test(currLink) && !/root_comment_id/.test(currLink)) {
  785. handleUrl(currLink, false);
  786. }
  787. }
  788. hot(currLink);
  789.  
  790. GM_addStyle(`
  791. .swal2-container {
  792. z-index: 99999;
  793. }
  794. #tex{
  795. padding-left: 1.4rem;
  796. }
  797. #tt{
  798. display: content;
  799. visibility: hidden
  800. }
  801. `);
  802. window.onload = function () {
  803. //图片下载按钮生成
  804. setTimeout(() => {
  805. // handleAllChaohua();
  806.  
  807. if (/weibo.com\/p/.test(currLink) || /d.weibo.com/.test(currLink)) {
  808. addBtn();
  809. }
  810. // hot(currLink);
  811. // let home = document.getElementsByClassName("Search_outer_3k7Aq")[0];
  812. // if (home != null) {
  813. // console.log("🌼生成超话按钮");
  814. // handleChaohua();
  815. // }
  816. }, 2000);
  817. };
  818. // Your code here...
  819. })();

QingJ © 2025

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