CSDN|简书优化

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

当前为 2023-12-16 提交的版本,查看 最新版本

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