CSDN优化

支持手机端和PC端,屏蔽广告,优化浏览体验,自动跳转拦截的URL

目前为 2024-02-08 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name CSDN优化
  3. // @icon https://www.csdn.net/favicon.ico
  4. // @namespace https://gf.qytechs.cn/zh-CN/scripts/406136
  5. // @supportURL https://github.com/WhiteSevs/TamperMonkeyScript/issues
  6. // @version 2024.2.8.16
  7. // @license MIT
  8. // @description 支持手机端和PC端,屏蔽广告,优化浏览体验,自动跳转拦截的URL
  9. // @author WhiteSevs
  10. // @match *://*.csdn.net/*
  11. // @grant GM_registerMenuCommand
  12. // @grant GM_unregisterMenuCommand
  13. // @grant GM_getValue
  14. // @grant GM_setValue
  15. // @grant GM_deleteValue
  16. // @grant GM_info
  17. // @grant unsafeWindow
  18. // @run-at document-start
  19. // @require https://update.gf.qytechs.cn/scripts/456485/1324038/pops.js
  20. // @require https://update.gf.qytechs.cn/scripts/455186/1324684/WhiteSevsUtils.js
  21. // @require https://update.gf.qytechs.cn/scripts/465772/1318702/DOMUtils.js
  22. // ==/UserScript==
  23.  
  24. (function () {
  25. /**
  26. * @type {import("../库/pops")}
  27. */
  28. const pops = window.pops;
  29. /**
  30. * @type {import("../库/Utils")}
  31. */
  32. const utils = window.Utils.noConflict();
  33. /**
  34. * @type {import("../库/DOMUtils")}
  35. */
  36. const DOMUtils = window.DOMUtils.noConflict();
  37. const log = new utils.Log(GM_info);
  38. log.config({
  39. autoClearConsole: false,
  40. });
  41. const GM_addStyle = utils.GM_addStyle;
  42. /**
  43. * 油猴菜单
  44. */
  45. const GM_Menu = new utils.GM_Menu({
  46. GM_getValue,
  47. GM_setValue,
  48. GM_registerMenuCommand,
  49. GM_unregisterMenuCommand,
  50. });
  51. /**
  52. * 移除元素(未出现也可以等待出现)
  53. * @param {string} selectorText 元素选择器
  54. */
  55. const waitForElementToRemove = function (selectorText = "") {
  56. utils.waitNodeList(selectorText).then((nodeList) => {
  57. nodeList.forEach((item) => {
  58. item.remove();
  59. });
  60. });
  61. };
  62.  
  63. const Optimization = {
  64. csdn: {
  65. /**
  66. * 判断是否是CSDN
  67. */
  68. locationMatch() {
  69. return Boolean(/csdn.net/i.test(window.location.origin));
  70. },
  71. PC: {
  72. /**
  73. * 初始化
  74. */
  75. init() {
  76. this.addCSS();
  77. if (PopsPanel.getValue("CSDNAutoJumpRedirect_PC")) {
  78. Optimization.csdn.PC.jumpRedirect();
  79. }
  80. if (PopsPanel.getValue("csdn_pc_cknow")) {
  81. this.cKnow();
  82. }
  83. if (PopsPanel.getValue("articleCenter")) {
  84. this.articleCenter();
  85. }
  86. if (PopsPanel.getValue("shieldLoginDialog")) {
  87. this.shieldLoginDialog();
  88. }
  89. if (PopsPanel.getValue("autoExpandContent")) {
  90. this.autoExpandContent();
  91. }
  92. if (PopsPanel.getValue("csdnShieldfloatingButton")) {
  93. this.shieldRightToolbar();
  94. }
  95. if (PopsPanel.getValue("csdnShieldBottomRecommendArticle")) {
  96. this.csdnShieldBottomRecommendArticle();
  97. }
  98. if (PopsPanel.getValue("csdnShieldBottomFloatingToolbar")) {
  99. this.csdnShieldBottomFloatingToolbar();
  100. }
  101. if (PopsPanel.getValue("csdn_pc_shieldLeftBlogContainerAside")) {
  102. this.shieldLeftBlogContainerAside();
  103. }
  104. if (PopsPanel.getValue("csdn_pc_shieldRightDirectoryInformation")) {
  105. this.shieldRightDirectoryInformation();
  106. }
  107. if (PopsPanel.getValue("csdn_pc_shieldTopToolbar")) {
  108. this.shieldTopToolbar();
  109. }
  110. this.initRightToolbarOffset();
  111. DOMUtils.ready(() => {
  112. if (PopsPanel.getValue("csdn_pc_removeClipboardHijacking")) {
  113. this.removeClipboardHijacking();
  114. }
  115. if (PopsPanel.getValue("csdn_pc_unBlockCopy")) {
  116. this.unBlockCopy();
  117. }
  118. if (PopsPanel.getValue("csdn_pc_identityCSDNDownload")) {
  119. this.identityCSDNDownload();
  120. }
  121. if (PopsPanel.getValue("csdn_pc_clickPreCodeAutomatically")) {
  122. this.clickPreCodeAutomatically();
  123. }
  124. if (PopsPanel.getValue("autoExpandContent")) {
  125. this.clickPreCodeAutomatically();
  126. }
  127. if (PopsPanel.getValue("csdn_pc_restoreComments")) {
  128. this.restoreComments();
  129. }
  130. if (PopsPanel.getValue("csdn_pc_addGotoRecommandButton")) {
  131. this.addGotoRecommandButton();
  132. }
  133. });
  134. if (window.location.hostname === "wenku.csdn.net") {
  135. this.addWenKuCSS();
  136. }
  137. },
  138. addCSS() {
  139. GM_addStyle(`
  140. .ecommend-item-box.recommend-recommend-box,
  141. .login-mark,
  142. .opt-box.text-center,
  143. .leftPop,
  144. #csdn-shop-window,
  145. .toolbar-advert,
  146. .hide-article-box,
  147. .user-desc.user-desc-fix,
  148. .recommend-card-box,
  149. .more-article,
  150. .article-show-more,
  151. #csdn-toolbar-profile-nologin,
  152. .guide-rr-first,
  153. #recommend-item-box-tow,
  154. /* 发文章得原力分图片提示 */
  155. div.csdn-toolbar-creative-mp,
  156. /* 阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。 */
  157. #toolBarBox div.write-guide-buttom-box,
  158. /* 觉得还不错? 一键收藏 */
  159. ul.toolbox-list div.tool-active-list,
  160. /* 右边按钮组的最上面的创作话题 */
  161. div.csdn-side-toolbar .activity-swiper-box,
  162. .sidetool-writeguide-box .tip-box,
  163. /* 右下角的登录(不可用)提示 */
  164. .passport-login-tip-container{
  165. display: none !important;
  166. }
  167. .comment-list-box,
  168. main div.blog-content-box pre{
  169. max-height: none !important;
  170. }
  171. .blog_container_aside,
  172. #nav{
  173. margin-left: -45px;
  174. }
  175. .recommend-right.align-items-stretch.clearfix,.dl_right_fixed{
  176. margin-left: 45px;
  177. }
  178. #content_views pre,
  179. #content_views pre code{
  180. user-select: text !important;
  181. }
  182. #article_content,
  183. .user-article.user-article-hide{
  184. height: auto !important;
  185. overflow: auto !important;
  186. }
  187. `);
  188. },
  189. /**
  190. * 添加在wenku.csdn.net下的CSS
  191. */
  192. addWenKuCSS() {
  193. GM_addStyle(`
  194. /* wenku顶部横幅 */
  195. #app > div > div.main.pb-32 > div > div.top-bar,
  196. /* 底部展开全文 */
  197. #chatgpt-article-detail > div.layout-center > div.main > div.article-box > div.cont.first-show.forbid > div.open{
  198. display: none !important;
  199. }
  200. #chatgpt-article-detail > div.layout-center > div.main > div.article-box > div.cont.first-show.forbid{
  201. max-height: unset !important;
  202. height: auto !important;
  203. overflow: auto !important;
  204. }
  205. `);
  206. GM_addStyle(`
  207. .forbid{
  208. user-select: text !important;
  209. }
  210. `);
  211. },
  212. /**
  213. * 去除剪贴板劫持
  214. */
  215. removeClipboardHijacking() {
  216. log.info("去除剪贴板劫持");
  217. document.querySelector(".article-copyright")?.remove();
  218. if (unsafeWindow.articleType) {
  219. unsafeWindow.articleType = 0;
  220. }
  221. if (
  222. unsafeWindow.csdn &&
  223. unsafeWindow.csdn.copyright &&
  224. unsafeWindow.csdn.copyright.textData
  225. ) {
  226. unsafeWindow.csdn.copyright.textData = "";
  227. }
  228. if (
  229. unsafeWindow.csdn &&
  230. unsafeWindow.csdn.copyright &&
  231. unsafeWindow.csdn.copyright.htmlData
  232. ) {
  233. unsafeWindow.csdn.copyright.htmlData = "";
  234. }
  235. },
  236. /**
  237. * 取消禁止复制
  238. */
  239. unBlockCopy() {
  240. log.info("取消禁止复制");
  241. document.addEventListener(
  242. "click",
  243. function (event) {
  244. let target = event.target;
  245. if (!target.classList.contains("hljs-button")) {
  246. return;
  247. }
  248. utils.preventEvent(event);
  249. /* 需要复制的文本 */
  250. let copyText =
  251. target.parentElement.innerText ||
  252. target.parentElement.textContent;
  253. utils.setClip(copyText);
  254. log.success("点击复制 复制成功~");
  255. target.setAttribute("data-title", "复制成功");
  256. },
  257. {
  258. capture: true,
  259. }
  260. );
  261. let changeDataTitle = new utils.LockFunction(function (event) {
  262. let target = event.target;
  263. if (!target.localName === "pre") {
  264. return;
  265. }
  266. target
  267. .querySelector(".hljs-button")
  268. ?.setAttribute("data-title", "复制");
  269. });
  270.  
  271. document.addEventListener("mouseenter", changeDataTitle.run, {
  272. capture: true,
  273. });
  274. document.addEventListener("mouseleave", changeDataTitle.run, {
  275. capture: true,
  276. });
  277. /* 取消Ctrl+C的禁止 */
  278. utils.waitNode("#content_views").then((element) => {
  279. unsafeWindow?.$("#content_views")?.unbind("copy");
  280. element.addEventListener("copy", function (event) {
  281. utils.preventEvent(event);
  282. utils.setClip(unsafeWindow.getSelection().toString());
  283. log.success("Ctrl+C 复制成功~");
  284. return false;
  285. });
  286. });
  287. /* 删除所有复制按钮的原有的复制事件 */
  288. utils.waitNode(".hljs-button").then(() => {
  289. setTimeout(() => {
  290. document.querySelectorAll(".hljs-button").forEach((element) => {
  291. element.removeAttribute("onclick");
  292. element.removeAttribute("data-report-click");
  293. element.setAttribute("data-title", "复制");
  294. });
  295. }, 250);
  296. });
  297. },
  298. /**
  299. * 点击代码块自动展开
  300. */
  301. clickPreCodeAutomatically() {
  302. log.info("点击代码块自动展开");
  303. document.addEventListener("click", function (event) {
  304. let target = event.target;
  305. if (target.localName !== "pre") {
  306. return;
  307. }
  308. target.style.setProperty("height", "auto");
  309. target.querySelector(".hide-preCode-box")?.remove();
  310. });
  311. },
  312. /**
  313. * 恢复评论到正确位置
  314. */
  315. restoreComments() {
  316. /* 第一条评论 */
  317. log.info("恢复评论到正确位置-第一条评论");
  318. utils.waitNode(".first-recommend-box").then((element) => {
  319. let recommendBoxElement = document.querySelector(
  320. ".recommend-box.insert-baidu-box.recommend-box-style"
  321. );
  322. recommendBoxElement.insertBefore(
  323. element,
  324. recommendBoxElement.firstChild
  325. );
  326. });
  327. log.info("恢复评论到正确位置-第二条评论");
  328. /* 第二条评论 */
  329. utils.waitNode(".second-recommend-box").then((element) => {
  330. let recommendBoxElement = document.querySelector(
  331. ".recommend-box.insert-baidu-box.recommend-box-style"
  332. );
  333. recommendBoxElement.insertBefore(
  334. element,
  335. recommendBoxElement.firstChild
  336. );
  337. });
  338. },
  339. /**
  340. * 标识CSDN下载的链接
  341. */
  342. identityCSDNDownload() {
  343. log.info("标识CSDN下载的链接");
  344. document
  345. .querySelectorAll(
  346. ".recommend-item-box[data-url*='https://download.csdn.net/']"
  347. )
  348. .forEach((item) => {
  349. if (PopsPanel.getValue("removeCSDNDownloadPC")) {
  350. item.remove();
  351. } else {
  352. item
  353. .querySelector(".content-box")
  354. .style.setProperty("border", "2px solid red");
  355. }
  356. });
  357. },
  358. /**
  359. * 全文居中
  360. */
  361. articleCenter() {
  362. log.info("全文居中");
  363. GM_addStyle(`
  364. #mainBox main{
  365. width: inherit !important;
  366. }
  367. `);
  368. GM_addStyle(`
  369. @media (min-width: 1320px) and (max-width:1380px) {
  370. .nodata .container {
  371. width: 900px !important
  372. }
  373. .nodata .container main {
  374. width: 900px
  375. }
  376. .nodata .container main #pcCommentBox pre >ol.hljs-ln {
  377. width: 490px !important
  378. }
  379. .nodata .container main .articleConDownSource {
  380. width: 500px
  381. }
  382. }
  383. @media screen and (max-width: 1320px) {
  384. .nodata .container {
  385. width: 760px !important
  386. }
  387. .nodata .container main {
  388. width: 760px
  389. }
  390. .nodata .container main #pcCommentBox pre >ol.hljs-ln {
  391. width: 490px !important
  392. }
  393. .nodata .container main .toolbox-list .tool-reward {
  394. display: none
  395. }
  396. .nodata .container main .more-toolbox-new .toolbox-left .profile-box .profile-name {
  397. max-width: 128px
  398. }
  399. .nodata .container main .articleConDownSource {
  400. width: 420px
  401. }
  402. }
  403. @media screen and (min-width: 1380px) {
  404. .nodata .container {
  405. width: 1010px !important
  406. }
  407. .nodata .container main {
  408. width: 1010px
  409. }
  410. .nodata .container main #pcCommentBox pre >ol.hljs-ln {
  411. width: 490px !important
  412. }
  413. .nodata .container main .articleConDownSource {
  414. width: 560px
  415. }
  416. }
  417. @media (min-width: 1550px) and (max-width:1700px) {
  418. .nodata .container {
  419. width: 820px !important
  420. }
  421. .nodata .container main {
  422. width: 820px
  423. }
  424. .nodata .container main #pcCommentBox pre >ol.hljs-ln {
  425. width: 690px !important
  426. }
  427. .nodata .container main .articleConDownSource {
  428. width: 500px
  429. }
  430. }
  431. @media screen and (min-width: 1700px) {
  432. .nodata .container {
  433. width: 1010px !important
  434. }
  435. .nodata .container main {
  436. width: 1010px
  437. }
  438. .nodata .container main #pcCommentBox pre >ol.hljs-ln {
  439. width: 690px !important
  440. }
  441. .nodata .container main .articleConDownSource {
  442. width: 560px
  443. }
  444. }
  445. `);
  446. },
  447. /**
  448. * 添加前往评论的按钮,在返回顶部的下面
  449. */
  450. addGotoRecommandButton() {
  451. log.info("添加前往评论的按钮,在返回顶部的上面");
  452. let gotoRecommandNode = document.createElement("a");
  453. gotoRecommandNode.className = "option-box";
  454. gotoRecommandNode.setAttribute("data-type", "gorecommand");
  455. gotoRecommandNode.innerHTML = `<span class="show-txt" style="display:flex;opacity:100;">前往<br>评论</span>`;
  456. gotoRecommandNode.addEventListener("click", function () {
  457. let toolbarBoxElement = document.querySelector("#toolBarBox");
  458. if (!toolbarBoxElement.getClientRects().length) {
  459. log.error("评论区处于隐藏状态");
  460. return;
  461. }
  462. log.info("滚动到评论");
  463. let toolbarBoxOffsetTop =
  464. toolbarBoxElement.getBoundingClientRect().top + window.scrollY;
  465. let csdnToolBarElement = document.querySelector("#csdn-toolbar");
  466. let csdnToolBarStyles = window.getComputedStyle(csdnToolBarElement);
  467. let csdnToolBarHeight =
  468. csdnToolBarElement.clientHeight -
  469. parseFloat(csdnToolBarStyles.paddingTop) -
  470. parseFloat(csdnToolBarStyles.paddingBottom);
  471. window.scrollTo({
  472. top: toolbarBoxOffsetTop - csdnToolBarHeight - 8,
  473. left: 0,
  474. behavior: "smooth",
  475. });
  476. });
  477. utils.waitNode(".csdn-side-toolbar").then(() => {
  478. let targetElement = document.querySelector(
  479. ".csdn-side-toolbar a:nth-last-child(2)"
  480. );
  481. targetElement.parentElement.insertBefore(
  482. gotoRecommandNode,
  483. targetElement.nextSibling
  484. );
  485. });
  486. },
  487. /**
  488. * 屏蔽登录(不可用)弹窗
  489. */
  490. shieldLoginDialog() {
  491. log.info("屏蔽登录(不可用)弹窗");
  492. GM_addStyle(`.passport-login-container{display: none !important;}`);
  493. },
  494. /**
  495. * 自动展开内容块
  496. */
  497. autoExpandContent() {
  498. log.info("自动展开内容块");
  499. GM_addStyle(`
  500. pre.set-code-hide{
  501. height: auto !important;
  502. }
  503. pre.set-code-hide .hide-preCode-box{
  504. display: none !important;
  505. }
  506. `);
  507. },
  508. /**
  509. * 屏蔽右侧工具栏
  510. */
  511. shieldRightToolbar() {
  512. log.info("屏蔽右侧工具栏");
  513. GM_addStyle(`
  514. div.csdn-side-toolbar{
  515. display: none !important;
  516. }
  517. `);
  518. },
  519. /**
  520. * 屏蔽底部推荐文章
  521. */
  522. csdnShieldBottomRecommendArticle() {
  523. log.info("屏蔽底部推荐文章");
  524. GM_addStyle(`
  525. main > div.recommend-box {
  526. display: none !important;
  527. }
  528. `);
  529. },
  530. /**
  531. * 屏蔽底部悬浮工具栏
  532. */
  533. csdnShieldBottomFloatingToolbar() {
  534. log.info("屏蔽底部悬浮工具栏");
  535. GM_addStyle(`
  536. #toolBarBox {
  537. display: none !important;
  538. }
  539. `);
  540. },
  541. /**
  542. * 屏蔽左侧博客信息
  543. */
  544. shieldLeftBlogContainerAside() {
  545. log.success("【屏蔽】左侧博客信息");
  546. GM_addStyle(`
  547. aside.blog_container_aside{
  548. display: none !important;
  549. }
  550. `);
  551. },
  552. /**
  553. * 【屏蔽】右侧目录信息
  554. */
  555. shieldRightDirectoryInformation() {
  556. log.success("【屏蔽】右侧目录信息");
  557. GM_addStyle(`
  558. #rightAsideConcision,
  559. #rightAside{
  560. display: none !important;
  561. }
  562. `);
  563. },
  564. /**
  565. * 屏蔽顶部Toolbar
  566. */
  567. shieldTopToolbar() {
  568. GM_addStyle(`
  569. #toolbarBox{
  570. display: none !important;
  571. }
  572. `);
  573. },
  574. /**
  575. * 去除CSDN拦截其它网址的url并自动跳转
  576. */
  577. jumpRedirect() {
  578. /* https://link.csdn.net/?target=https%3A%2F%2Fjaist.dl.sourceforge.net%2Fproject%2Fportecle%2Fv1.11%2Fportecle-1.11.zip */
  579. if (
  580. window.location.hostname === "link.csdn.net" &&
  581. window.location.search.startsWith("?target")
  582. ) {
  583. /* 禁止CSDN拦截跳转 */
  584. window.stop();
  585. let search = window.location.search.replace(/^\?target=/gi, "");
  586. search = decodeURIComponent(search);
  587. let newURL = search;
  588. log.success(`跳转链接 ${newURL}`);
  589. window.location.href = newURL;
  590. }
  591. },
  592. /**
  593. * C知道
  594. */
  595. cKnow() {
  596. if (!window.location.href.startsWith("https://so.csdn.net/so/ai")) {
  597. return;
  598. }
  599. GM_addStyle(`
  600. div.username_mask_cover{
  601. background-image: none !important;
  602. }
  603. `);
  604. },
  605. /**
  606. * 初始化右侧工具栏的偏移(top、right)
  607. */
  608. initRightToolbarOffset() {
  609. GM_addStyle(`
  610. .csdn-side-toolbar{
  611. left: unset !important;
  612. }
  613. `);
  614. utils.waitNode(".csdn-side-toolbar").then((element) => {
  615. DOMUtils.css(element, {
  616. top:
  617. parseInt(PopsPanel.getValue("csdn_pc_rightToolbarTopOffset")) +
  618. "px",
  619. right:
  620. parseInt(
  621. PopsPanel.getValue("csdn_pc_rightToolbarRightOffset")
  622. ) + "px",
  623. });
  624. });
  625. },
  626. },
  627. Mobile: {
  628. /**
  629. * 初始化
  630. */
  631. init() {
  632. this.addCSS();
  633. if (PopsPanel.getValue("csdn_mobile_shieldTopToolbar")) {
  634. this.shieldTopToolbar();
  635. }
  636. if (PopsPanel.getValue("CSDNAutoJumpRedirect_Mobile")) {
  637. Optimization.csdn.PC.jumpRedirect();
  638. }
  639. if (PopsPanel.getValue("csdn_mobile_cknow")) {
  640. this.cKnow();
  641. }
  642. DOMUtils.ready(() => {
  643. if (PopsPanel.getValue("csdn_mobile_removeAds")) {
  644. this.removeAds();
  645. }
  646. if (PopsPanel.getValue("csdn_mobile_refactoringRecommendation")) {
  647. this.refactoringRecommendation();
  648. }
  649. if (PopsPanel.getValue("csdn_mobile_unBlockCopy")) {
  650. Optimization.csdn.PC.unBlockCopy();
  651. }
  652. });
  653. },
  654. addCSS() {
  655. GM_addStyle(`
  656. #mainBox{
  657. width: auto;
  658. }
  659. .user-desc.user-desc-fix{
  660. height: auto !important;
  661. overflow: auto !important;
  662. }
  663. #operate,.feed-Sign-span,
  664. .view_comment_box,
  665. .weixin-shadowbox.wap-shadowbox,
  666. .feed-Sign-span,
  667. .user-desc.user-desc-fix,
  668. .comment_read_more_box,
  669. #content_views pre.set-code-hide .hide-preCode-box,
  670. .passport-login-container,
  671. .hljs-button[data-title='登录(不可用)后复制'],
  672. .article-show-more,
  673. #treeSkill,
  674. div.btn_open_app_prompt_div,
  675. div.readall_box,
  676. div.aside-header-fixed,
  677. div.feed-Sign-weixin,
  678. div.ios-shadowbox{
  679. display:none !important;
  680. }
  681. .component-box .praise {
  682. background: #ff5722;
  683. border-radius: 5px;
  684. padding: 0px 8px;
  685. height: auto;
  686. }
  687. .component-box .praise,.component-box .share {
  688. color: #fff;
  689. }
  690. .component-box a {
  691. display: inline-block;
  692. font-size:xx-small;
  693. }
  694. .component-box {
  695. display: inline;
  696. margin: 0;
  697. position: relative;
  698. white-space:nowrap;
  699. }
  700. .csdn-edu-title{
  701. background: #4d6de1;
  702. border-radius: 5px;
  703. padding: 0px 8px;
  704. height: auto;
  705. color: #fff !important;
  706. }
  707. #comment{
  708. max-height: none !important;
  709. }
  710. #content_views pre,
  711. #content_views pre code{
  712. webkit-touch-callout: text !important;
  713. -webkit-user-select: text !important;
  714. -khtml-user-select: text !important;
  715. -moz-user-select: text !important;
  716. -ms-user-select: text !important;
  717. user-select: text !important;
  718. }
  719. #content_views pre.set-code-hide,
  720. .article_content{
  721. height: 100% !important;
  722. overflow: auto !important;
  723. }`);
  724. GM_addStyle(`
  725. .GM-csdn-dl{
  726. padding: .24rem .32rem;
  727. width: 100%;
  728. justify-content: space-between;
  729. -webkit-box-pack: justify;
  730. border-bottom: 1px solid #F5F6F7!important;
  731. }
  732. .GM-csdn-title{
  733. font-size: .3rem;
  734. color: #222226;
  735. letter-spacing: 0;
  736. line-height: .44rem;
  737. font-weight: 600;
  738. //max-height: .88rem;
  739. word-break: break-all;
  740. overflow: hidden;
  741. display: -webkit-box;
  742. -webkit-box-orient: vertical;
  743. -webkit-line-clamp: 2
  744. }
  745. .GM-csdn-title a{
  746. word-break: break-all;
  747. color: #222226;
  748. font-weight: 600;
  749. }
  750. .GM-csdn-title em,.GM-csdn-content em{
  751. font-style: normal;
  752. color: #fc5531
  753. }
  754. .GM-csdn-content{
  755. //max-width: 5.58rem;
  756. overflow: hidden;
  757. text-overflow: ellipsis;
  758. display: -webkit-box;
  759. -webkit-line-clamp: 1;
  760. -webkit-box-orient: vertical;
  761. color: #555666;
  762. font-size: .24rem;
  763. line-height: .34rem;
  764. max-height: .34rem;
  765. word-break: break-all;
  766. -webkit-box-flex: 1;
  767. -ms-flex: 1;
  768. flex: 1;
  769. margin-top: .16rem;
  770. }
  771. .GM-csdn-img img{
  772. width: 2.18rem;
  773. height: 1.58rem;
  774. //margin-left: .16rem
  775. }`);
  776. },
  777. /**
  778. * 屏蔽顶部Toolbar
  779. */
  780. shieldTopToolbar() {
  781. GM_addStyle(`
  782. #csdn-toolbar{
  783. display: none !important;
  784. }
  785. /* 内容顶部要归位 */
  786. body #main,
  787. .margin_sides{
  788. margin-top: unset !important;
  789. padding-top: unset !important;
  790. }
  791. #article .article_title{
  792. margin-top: .32rem !important;
  793. padding-top: unset !important;
  794. }
  795. `);
  796. },
  797. /**
  798. * 重构底部推荐
  799. */
  800. refactoringRecommendation() {
  801. function refactoring() {
  802. /* 反复执行的重构函数 */
  803. log.success("重构底部推荐");
  804. document.querySelectorAll(".container-fluid").forEach((item) => {
  805. /* 链接 */
  806. let url = "";
  807. /* 标题 */
  808. let title = "";
  809. /* 内容 */
  810. let content = "";
  811. /* 图片 */
  812. let img = "";
  813. /* 判断是否是CSDN资源下载 */
  814. let isCSDNDownload = false;
  815. /* 判断是否是CSDN-学院资源下载 */
  816. let isCSDNEduDownload = false;
  817. if (item.hasAttribute("data-url")) {
  818. /* 存在真正的URL */
  819. url = item.getAttribute("data-url");
  820. title = item.querySelector(
  821. ".recommend_title div.left"
  822. ).innerHTML;
  823. content = item.querySelector(".text").innerHTML;
  824. if (item.querySelectorAll(".recommend-img").length) {
  825. /* 如果有图片就加进去 */
  826. item.querySelectorAll(".recommend-img").forEach((item2) => {
  827. img += item2.innerHTML;
  828. });
  829. }
  830. } else {
  831. log.info("节点上无data-url");
  832. url = item.querySelector("a[data-type]").getAttribute("href");
  833. title = item.querySelector(
  834. ".recommend_title div.left"
  835. ).innerHTML;
  836. content = item.querySelector(".text").innerHTML;
  837. }
  838. var _URL_ = new URL(url);
  839. if (
  840. _URL_.host === "download.csdn.net" ||
  841. (_URL_.host === "www.iteye.com" &&
  842. _URL_.pathname.match(/^\/resource/gi))
  843. ) {
  844. /* 该链接为csdn资源下载 */
  845. log.info("该链接为csdn资源下载");
  846. isCSDNDownload = true;
  847. title =
  848. `<div class="component-box"><a class="praise" href="javascript:;">CSDN下载</a></div>` +
  849. title;
  850. } else if (_URL_.origin.match(/edu.csdn.net/gi)) {
  851. /* 该链接为csdn学院下载 */
  852. isCSDNEduDownload = true;
  853. log.info("该链接为csdn学院下载");
  854. title =
  855. `<div class="component-box"><a class="csdn-edu-title" href="javascript:;">CSDN学院</a></div>` +
  856. title;
  857. }
  858. item.setAttribute("class", "GM-csdn-dl");
  859. item.setAttribute("data-url", url);
  860. item.innerHTML = `<div class="GM-csdn-title"><div class="left">${title}</div></div><div class="GM-csdn-content">${content}</div><div class="GM-csdn-img">${img}</div>`;
  861. item.addEventListener("click", function () {
  862. if (PopsPanel.getValue("openNewTab")) {
  863. window.open(url, "_blank");
  864. } else {
  865. window.location.href = url;
  866. }
  867. });
  868. if (
  869. (isCSDNDownload || isCSDNEduDownload) &&
  870. PopsPanel.getValue("removeCSDNDownloadMobile")
  871. ) {
  872. item.remove();
  873. }
  874. });
  875. }
  876. let lockFunction = new utils.LockFunction(refactoring, this, 50);
  877. utils.waitNode("#recommend").then((element) => {
  878. lockFunction.run();
  879. utils.mutationObserver(element, {
  880. callback: lockFunction.run,
  881. config: { childList: true, subtree: true, attributes: true },
  882. });
  883. });
  884. },
  885. /**
  886. * 去除广告
  887. */
  888. removeAds() {
  889. log.info("去除广告");
  890. /* 登录(不可用)窗口 */
  891. waitForElementToRemove(".passport-login-container");
  892. /* 打开APP */
  893. waitForElementToRemove(
  894. ".btn_open_app_prompt_box.detail-open-removed"
  895. );
  896. /* 广告 */
  897. waitForElementToRemove(".add-firstAd");
  898. /* 打开CSDN APP 小程序看全文 */
  899. waitForElementToRemove("div.feed-Sign-weixin");
  900. /* ios版本提示 */
  901. waitForElementToRemove("div.ios-shadowbox");
  902. },
  903. /**
  904. * C知道
  905. */
  906. cKnow() {
  907. if (!window.location.href.startsWith("https://so.csdn.net/so/ai")) {
  908. return;
  909. }
  910. GM_addStyle(`
  911. div.username_mask_cover{
  912. background-image: none !important;
  913. }
  914. `);
  915. },
  916. },
  917. /**
  918. * 函数入口
  919. */
  920. init() {
  921. if (utils.isPhone()) {
  922. log.success("移动端模式");
  923. this.Mobile.init();
  924. } else {
  925. log.success("桌面端模式");
  926. this.PC.init();
  927. }
  928. },
  929. },
  930. huaWeiCSDN: {
  931. /**
  932. * 判断是否是CSDN
  933. */
  934. locationMatch() {
  935. return Boolean(/huaweicloud.csdn.net/i.test(window.location.origin));
  936. },
  937. PC: {
  938. /**
  939. * 初始化
  940. */
  941. init() {
  942. this.addCSS();
  943. if (
  944. PopsPanel.getValue(
  945. "huaweiCSDNShieldCloudDeveloperTaskChallengeEvent"
  946. )
  947. ) {
  948. this.huaweiCSDNShieldCloudDeveloperTaskChallengeEvent();
  949. }
  950. if (PopsPanel.getValue("huaweiCSDNShieldLeftFloatingButton")) {
  951. this.huaweiCSDNShieldLeftFloatingButton();
  952. }
  953. if (PopsPanel.getValue("huaweiCSDNBlockRightColumn")) {
  954. this.huaweiCSDNBlockRightColumn();
  955. }
  956. if (
  957. PopsPanel.getValue("huaweiCSDNBlockRecommendedContentAtTheBottom")
  958. ) {
  959. this.huaweiCSDNBlockRecommendedContentAtTheBottom();
  960. }
  961. if (
  962. PopsPanel.getValue(
  963. "huaweiCSDNShieldTheBottomForMoreRecommendations"
  964. )
  965. ) {
  966. this.huaweiCSDNShieldTheBottomForMoreRecommendations();
  967. }
  968. },
  969. addCSS() {
  970. GM_addStyle(`
  971. /* 底部免费抽xxx奖品广告 */
  972. div.siderbar-box,
  973. /* 华为开发者联盟加入社区 */
  974. div.user-desc.user-desc-fix,
  975. /* 点击阅读全文 */
  976. div.article-show-more{
  977. display: none !important;
  978. }
  979.  
  980. /* 自动展开全文 */
  981. .main-content .user-article{
  982. height: auto !important;
  983. overflow: auto !important;
  984. }
  985. `);
  986. },
  987. /**
  988. * 屏蔽云开发者任务挑战活动
  989. */
  990. huaweiCSDNShieldCloudDeveloperTaskChallengeEvent() {
  991. let GM_cookie = new utils.GM_Cookie();
  992. GM_cookie.set({ name: "show_join_group_index", value: 1 });
  993. log.success("屏蔽云开发者任务挑战活动");
  994. },
  995. /**
  996. * 屏蔽左侧悬浮按钮
  997. */
  998. huaweiCSDNShieldLeftFloatingButton() {
  999. log.success(
  1000. "屏蔽左侧悬浮按钮,包括当前阅读量、点赞按钮、评论按钮、分享按钮"
  1001. );
  1002. GM_addStyle(`
  1003. div.toolbar-wrapper.article-interact-bar{
  1004. display: none !important;
  1005. }`);
  1006. },
  1007. /**
  1008. * 屏蔽右侧栏
  1009. */
  1010. huaweiCSDNBlockRightColumn() {
  1011. log.success("屏蔽右侧栏,包括相关产品-活动日历-运营活动-热门标签");
  1012. GM_addStyle(`
  1013. div.page-home-right.dp-aside-right{
  1014. display: none !important;
  1015. }
  1016. `);
  1017. },
  1018. /**
  1019. * 屏蔽底部推荐内容
  1020. */
  1021. huaweiCSDNBlockRecommendedContentAtTheBottom() {
  1022. log.success("屏蔽底部推荐内容");
  1023. GM_addStyle(`
  1024. div.recommend-card-box{
  1025. display: none !important;
  1026. }`);
  1027. },
  1028. /**
  1029. * 屏蔽底部更多推荐
  1030. */
  1031. huaweiCSDNShieldTheBottomForMoreRecommendations() {
  1032. log.success("屏蔽底部更多推荐");
  1033. GM_addStyle(`
  1034. div.more-article{
  1035. display: none !important;
  1036. }`);
  1037. },
  1038. },
  1039. },
  1040. };
  1041.  
  1042. /**
  1043. * 配置面板
  1044. */
  1045. const PopsPanel = {
  1046. /**
  1047. * 本地存储的总键名
  1048. */
  1049. key: "GM_Panel",
  1050. /**
  1051. * 属性attributes的data-key
  1052. */
  1053. attributeDataKey_Name: "data-key",
  1054. /**
  1055. * 属性attributes的data-default-value
  1056. */
  1057. attributeDataDefaultValue_Name: "data-default-value",
  1058. /**
  1059. * 初始化菜单
  1060. */
  1061. initMenu() {
  1062. this.initLocalDefaultValue();
  1063. GM_Menu.add([
  1064. {
  1065. key: "show_pops_panel_setting",
  1066. text: "⚙ 设置",
  1067. autoReload: false,
  1068. isStoreValue: false,
  1069. showText(text) {
  1070. return text;
  1071. },
  1072. callback: () => {
  1073. this.showPanel();
  1074. },
  1075. },
  1076. {
  1077. key: "transfer_old_data",
  1078. text: "🔧 迁移旧数据",
  1079. autoReload: false,
  1080. isStoreValue: false,
  1081. showText(text) {
  1082. return text;
  1083. },
  1084. callback: () => {
  1085. this.transferOldData();
  1086. },
  1087. },
  1088. ]);
  1089. },
  1090. /**
  1091. * 初始化本地设置默认的值
  1092. */
  1093. initLocalDefaultValue() {
  1094. let content = this.getContent();
  1095. content.forEach((item) => {
  1096. if (!item["forms"]) {
  1097. return;
  1098. }
  1099. item.forms.forEach((__item__) => {
  1100. if (__item__.forms) {
  1101. __item__.forms.forEach((containerItem) => {
  1102. if (!containerItem.attributes) {
  1103. return;
  1104. }
  1105. let key = containerItem.attributes[this.attributeDataKey_Name];
  1106. let defaultValue =
  1107. containerItem.attributes[this.attributeDataDefaultValue_Name];
  1108. if (this.getValue(key) == null) {
  1109. this.setValue(key, defaultValue);
  1110. }
  1111. });
  1112. } else {
  1113. }
  1114. });
  1115. });
  1116. },
  1117. /**
  1118. * 设置值
  1119. * @param {string} key 键
  1120. * @param {any} value 值
  1121. */
  1122. setValue(key, value) {
  1123. let localValue = GM_getValue(this.key, {});
  1124. localValue[key] = value;
  1125. GM_setValue(this.key, localValue);
  1126. },
  1127. /**
  1128. * 获取值
  1129. * @param {string} key 键
  1130. * @param {any} defaultValue 默认值
  1131. * @returns {any}
  1132. */
  1133. getValue(key, defaultValue) {
  1134. let localValue = GM_getValue(this.key, {});
  1135. return localValue[key] ?? defaultValue;
  1136. },
  1137. /**
  1138. * 删除值
  1139. * @param {string} key 键
  1140. */
  1141. deleteValue(key) {
  1142. let localValue = GM_getValue(this.key, {});
  1143. delete localValue[key];
  1144. GM_setValue(this.key, localValue);
  1145. },
  1146. /**
  1147. * 显示设置面板
  1148. */
  1149. showPanel() {
  1150. pops.panel({
  1151. title: {
  1152. text: `${GM_info?.script?.name || "CSDN优化"}-设置`,
  1153. position: "center",
  1154. },
  1155. content: this.getContent(),
  1156. mask: {
  1157. enable: true,
  1158. clickEvent: {
  1159. toClose: true,
  1160. },
  1161. },
  1162. width: pops.isPhone() ? "92vw" : "800px",
  1163. height: pops.isPhone() ? "80vh" : "600px",
  1164. only: true,
  1165. drag: true,
  1166. });
  1167. },
  1168. /**
  1169. * 获取按钮配置
  1170. * @param {string} text 文字
  1171. * @param {string} key 键
  1172. * @param {boolean} defaultValue 默认值
  1173. * @param {?(event:Event,value: boolean)=>boolean} _callback_ 点击回调
  1174. * @param {string|undefined} description 描述
  1175. */
  1176. getSwtichDetail(text, key, defaultValue, _callback_, description) {
  1177. /**
  1178. * @type {PopsPanelSwitchDetails}
  1179. */
  1180. let result = {
  1181. text: text,
  1182. type: "switch",
  1183. description: description,
  1184. attributes: {},
  1185. getValue() {
  1186. return Boolean(PopsPanel.getValue(key, defaultValue));
  1187. },
  1188. callback(event, value) {
  1189. log.success(`${value ? "开启" : "关闭"} ${text}`);
  1190. if (typeof _callback_ === "function") {
  1191. if (_callback_(event, value)) {
  1192. return;
  1193. }
  1194. }
  1195. PopsPanel.setValue(key, value);
  1196. },
  1197. };
  1198. result.attributes[this.attributeDataKey_Name] = key;
  1199. result.attributes[this.attributeDataDefaultValue_Name] =
  1200. Boolean(defaultValue);
  1201. return result;
  1202. },
  1203. /**
  1204. * 获取配置内容
  1205. */
  1206. getContent() {
  1207. return [
  1208. {
  1209. id: "csdn-panel-config-pc",
  1210. title: "桌面端",
  1211. forms: [
  1212. {
  1213. text: "屏蔽",
  1214. type: "forms",
  1215. forms: [
  1216. PopsPanel.getSwtichDetail(
  1217. "【屏蔽】登录(不可用)弹窗",
  1218. "shieldLoginDialog",
  1219. true
  1220. ),
  1221. PopsPanel.getSwtichDetail(
  1222. "【屏蔽】底部文章",
  1223. "csdnShieldBottomRecommendArticle",
  1224. false
  1225. ),
  1226. PopsPanel.getSwtichDetail(
  1227. "【屏蔽】底部文章中的CSDN下载文章",
  1228. "removeCSDNDownloadPC",
  1229. false
  1230. ),
  1231. PopsPanel.getSwtichDetail(
  1232. "【屏蔽】左侧博客信息",
  1233. "csdn_pc_shieldLeftBlogContainerAside",
  1234. false
  1235. ),
  1236. PopsPanel.getSwtichDetail(
  1237. "【屏蔽】右侧目录信息",
  1238. "csdn_pc_shieldRightDirectoryInformation",
  1239. false
  1240. ),
  1241. PopsPanel.getSwtichDetail(
  1242. "【屏蔽】右侧工具栏",
  1243. "csdnShieldfloatingButton",
  1244. false
  1245. ),
  1246. PopsPanel.getSwtichDetail(
  1247. "【屏蔽】顶部工具栏",
  1248. "csdn_pc_shieldTopToolbar",
  1249. false
  1250. ),
  1251. PopsPanel.getSwtichDetail(
  1252. "【屏蔽】底部的悬浮工具栏",
  1253. "csdnShieldBottomFloatingToolbar",
  1254. false
  1255. ),
  1256. PopsPanel.getSwtichDetail(
  1257. "【屏蔽】C知道的背景水印",
  1258. "csdn_pc_cknow",
  1259. false
  1260. ),
  1261. ],
  1262. },
  1263. {
  1264. text: "功能",
  1265. type: "forms",
  1266. forms: [
  1267. {
  1268. text: "右侧工具栏的right偏移",
  1269. type: "slider",
  1270. attributes: {
  1271. "data-key": "csdn_pc_rightToolbarRightOffset",
  1272. "data-default-value": 90,
  1273. },
  1274. getValue() {
  1275. return PopsPanel.getValue(
  1276. this.attributes["data-key"],
  1277. this.attributes["data-default-value"]
  1278. );
  1279. },
  1280. getToolTipContent(value) {
  1281. return `当前:${value}px,默认:${this.attributes["data-default-value"]}px`;
  1282. },
  1283. callback(event, value) {
  1284. PopsPanel.setValue(this.attributes["data-key"], value);
  1285. let csdnSideToolbar =
  1286. document.querySelector(".csdn-side-toolbar");
  1287. DOMUtils.css(csdnSideToolbar, {
  1288. right: value + "px",
  1289. });
  1290. },
  1291. min: 0,
  1292. max: document.documentElement.clientWidth,
  1293. },
  1294. {
  1295. text: "右侧工具栏的top偏移",
  1296. type: "slider",
  1297. attributes: {
  1298. "data-key": "csdn_pc_rightToolbarTopOffset",
  1299. "data-default-value": 140,
  1300. },
  1301. getValue() {
  1302. return PopsPanel.getValue(
  1303. this.attributes["data-key"],
  1304. this.attributes["data-default-value"]
  1305. );
  1306. },
  1307. getToolTipContent(value) {
  1308. return `当前:${value}px,默认:${this.attributes["data-default-value"]}px`;
  1309. },
  1310. callback(event, value) {
  1311. PopsPanel.setValue(this.attributes["data-key"], value);
  1312. let csdnSideToolbar =
  1313. document.querySelector(".csdn-side-toolbar");
  1314. DOMUtils.css(csdnSideToolbar, {
  1315. top: value + "px",
  1316. });
  1317. },
  1318. min: 0,
  1319. max: document.documentElement.clientHeight,
  1320. },
  1321. PopsPanel.getSwtichDetail(
  1322. "全文居中",
  1323. "articleCenter",
  1324. true,
  1325. function (event, enable) {
  1326. if (enable) {
  1327. alert(
  1328. "为了更好的呈现效果,请开启功能:【屏蔽】左侧博客信息、【屏蔽】右侧目录信息"
  1329. );
  1330. }
  1331. }
  1332. ),
  1333. PopsPanel.getSwtichDetail(
  1334. "自动展开内容块",
  1335. "autoExpandContent",
  1336. false
  1337. ),
  1338. PopsPanel.getSwtichDetail(
  1339. "重定向链接",
  1340. "CSDNAutoJumpRedirect_PC",
  1341. true,
  1342. undefined,
  1343. "自动跳转CSDN拦截的Url链接"
  1344. ),
  1345. PopsPanel.getSwtichDetail(
  1346. "标识底部文章的CSDN下载",
  1347. "csdn_pc_identityCSDNDownload",
  1348. true
  1349. ),
  1350. PopsPanel.getSwtichDetail(
  1351. "优化评论的位置",
  1352. "csdn_pc_restoreComments",
  1353. true
  1354. ),
  1355. PopsPanel.getSwtichDetail(
  1356. "添加前往评论的按钮",
  1357. "csdn_pc_addGotoRecommandButton",
  1358. true
  1359. ),
  1360. ],
  1361. },
  1362. {
  1363. text: "劫持/拦截",
  1364. type: "forms",
  1365. forms: [
  1366. PopsPanel.getSwtichDetail(
  1367. "拦截-复制的小尾巴",
  1368. "csdn_pc_removeClipboardHijacking",
  1369. true
  1370. ),
  1371. PopsPanel.getSwtichDetail(
  1372. "劫持-禁止复制",
  1373. "csdn_pc_unBlockCopy",
  1374. true,
  1375. undefined,
  1376. "允许点击复制按钮进行复制"
  1377. ),
  1378. ],
  1379. },
  1380. ],
  1381. },
  1382. {
  1383. id: "csdn-panel-config-mobile",
  1384. title: "移动端",
  1385. forms: [
  1386. {
  1387. text: "屏蔽",
  1388. type: "forms",
  1389. forms: [
  1390. PopsPanel.getSwtichDetail(
  1391. "【屏蔽】广告",
  1392. "csdn_mobile_removeAds",
  1393. true
  1394. ),
  1395. PopsPanel.getSwtichDetail(
  1396. "【屏蔽】底部的CSDN下载文章",
  1397. "removeCSDNDownloadMobile",
  1398. false
  1399. ),
  1400. PopsPanel.getSwtichDetail(
  1401. "【屏蔽】C知道的背景水印",
  1402. "csdn_mobile_cknow",
  1403. true
  1404. ),
  1405. PopsPanel.getSwtichDetail(
  1406. "【屏蔽】顶部Toolbar",
  1407. "csdn_mobile_shieldTopToolbar",
  1408. false
  1409. ),
  1410. ],
  1411. },
  1412. {
  1413. text: "功能",
  1414. type: "forms",
  1415. forms: [
  1416. PopsPanel.getSwtichDetail(
  1417. "底部文章新标签页打开",
  1418. "openNewTab",
  1419. true
  1420. ),
  1421. PopsPanel.getSwtichDetail(
  1422. "重定向链接",
  1423. "CSDNAutoJumpRedirect_Mobile",
  1424. true,
  1425. undefined,
  1426. "自动跳转CSDN拦截的Url链接"
  1427. ),
  1428. PopsPanel.getSwtichDetail(
  1429. "重构底部推荐",
  1430. "csdn_mobile_refactoringRecommendation",
  1431. true
  1432. ),
  1433. ],
  1434. },
  1435. {
  1436. text: "劫持/拦截",
  1437. type: "forms",
  1438. forms: [
  1439. PopsPanel.getSwtichDetail(
  1440. "劫持-禁止复制",
  1441. "csdn_mobile_unBlockCopy",
  1442. true,
  1443. undefined,
  1444. "允许点击复制按钮进行复制"
  1445. ),
  1446. ],
  1447. },
  1448. ],
  1449. },
  1450. {
  1451. id: "csdn-panel-config-huawei",
  1452. title: "华为云开发者联盟",
  1453. forms: [
  1454. {
  1455. text: "屏蔽",
  1456. type: "forms",
  1457. forms: [
  1458. PopsPanel.getSwtichDetail(
  1459. "【屏蔽】云开发者任务挑战活动",
  1460. "huaweiCSDNShieldCloudDeveloperTaskChallengeEvent",
  1461. true
  1462. ),
  1463. PopsPanel.getSwtichDetail(
  1464. "【屏蔽】左侧悬浮按钮",
  1465. "huaweiCSDNShieldLeftFloatingButton",
  1466. false,
  1467. function (event, enable) {
  1468. if (enable) {
  1469. alert(
  1470. "开启后将屏蔽【当前阅读量】、【点赞按钮】、【评论按钮】、【分享按钮】"
  1471. );
  1472. }
  1473. }
  1474. ),
  1475. PopsPanel.getSwtichDetail(
  1476. "【屏蔽】右侧栏",
  1477. "huaweiCSDNBlockRightColumn",
  1478. false,
  1479. function (event, enable) {
  1480. if (enable) {
  1481. alert(
  1482. "开启后将屏蔽【相关产品】-【活动日历】-【运营活动】-【热门标签】"
  1483. );
  1484. }
  1485. }
  1486. ),
  1487. PopsPanel.getSwtichDetail(
  1488. "【屏蔽】底部推荐内容",
  1489. "huaweiCSDNBlockRecommendedContentAtTheBottom",
  1490. false
  1491. ),
  1492. PopsPanel.getSwtichDetail(
  1493. "【屏蔽】底部更多推荐",
  1494. "huaweiCSDNShieldTheBottomForMoreRecommendations",
  1495. false
  1496. ),
  1497. ],
  1498. },
  1499. ],
  1500. },
  1501. ];
  1502. },
  1503. /**
  1504. * 迁移旧数据
  1505. */
  1506. transferOldData() {
  1507. let oldData = GM_getValue("GM_Menu_Local_Map");
  1508. let currentData = GM_getValue(this.key, {});
  1509. if (oldData) {
  1510. Object.assign(currentData, oldData);
  1511. GM_setValue(this.key, currentData);
  1512. GM_deleteValue("GM_Menu_Local_Map");
  1513. alert("共迁移数据量:" + Object.keys(oldData).length);
  1514. } else {
  1515. alert("不存在旧数据");
  1516. }
  1517. },
  1518. };
  1519.  
  1520. PopsPanel.initMenu();
  1521.  
  1522. if (Optimization.huaWeiCSDN.locationMatch()) {
  1523. Optimization.huaWeiCSDN.PC.init();
  1524. } else if (Optimization.csdn.locationMatch()) {
  1525. GM_Menu.add({
  1526. key: "gotoCSDNCKnow",
  1527. text: "⚙ 前往C知道",
  1528. autoReload: false,
  1529. showText(text) {
  1530. return text;
  1531. },
  1532. callback() {
  1533. window.open("https://so.csdn.net/so/ai?", "_blank");
  1534. },
  1535. });
  1536. Optimization.csdn.init();
  1537. } else {
  1538. log.error("暂未适配,请反馈开发者:" + globalThis.location.href);
  1539. }
  1540. })();

QingJ © 2025

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