CSDN Greener

CSDN 专杀,广告统统滚开,内容样式统一,我就要我觉得

当前为 2022-08-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CSDN Greener
  3. // @version 0.0.10
  4. // @description CSDN 专杀,广告统统滚开,内容样式统一,我就要我觉得
  5. // @author gausszhou@qq.com
  6. // @namespace gausszhou
  7. // @grant none
  8. // @run-at document-start
  9. // @license MIT
  10. // @icon https://www.gausszhou.top/favicon.ico
  11. // @include *://*.csdn.net/*
  12. // @include *://csdn.net/*
  13. // ==/UserScript==
  14.  
  15. /******/ (() => { // webpackBootstrap
  16. /******/ "use strict";
  17. /******/ var __webpack_modules__ = ({
  18.  
  19. /***/ 737:
  20. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  21.  
  22. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  23. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  24. /* harmony export */ });
  25. /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(601);
  26. /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  27. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(609);
  28. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  29. // Imports
  30.  
  31.  
  32. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  33. // Module
  34. ___CSS_LOADER_EXPORT___.push([module.id, "body{display:none}.csdn .blog-footer-bottom{display:none !important}.csdn .user-profile-head .user-profile-head-banner{height:2rem !important}.csdn .toolbar-menus.csdn-toolbar-fl,.csdn .toolbar-container-middle,.csdn .toolbar-container-right{display:none}.csdn .toolbar-container .title-article{font-size:1.25rem;width:100%}.csdn.menu .csdn-side-toolbar,.csdn.menu .user-spm-list,.csdn.menu .user-influence-list,.csdn.menu .user-achievement,.csdn.menu #asideProfile,.csdn.menu #asideNewComments{display:none !important}.csdn.article #asideProfile,.csdn.article #asideCategory,.csdn.article #asideNewComments,.csdn.article #asideNewNps,.csdn.article #asideArchive,.csdn.article #asideHotArticle,.csdn.article #asideSearchArticle,.csdn.article #asideCustom,.csdn.article #asidedirectory,.csdn.article #btnMoreComment,.csdn.article .recommend-box,.csdn.article .recommend-right_aside .toolbar-advert{display:none !important}.csdn.article .main_father{max-width:800px;margin:0 auto}.csdn.article .blog-content-box{margin-top:0}.csdn.article .template-box{margin-bottom:1em}.csdn.article blockquote{margin:0.5em !important;padding:1em !important;border-left:5px solid #005282 !important;background-color:#f4f4f4 !important;color:#1b1b1b !important}\n", ""]);
  35. // Exports
  36. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  37.  
  38.  
  39. /***/ }),
  40.  
  41. /***/ 609:
  42. /***/ ((module) => {
  43.  
  44.  
  45.  
  46. /*
  47. MIT License http://www.opensource.org/licenses/mit-license.php
  48. Author Tobias Koppers @sokra
  49. */
  50. module.exports = function (cssWithMappingToString) {
  51. var list = []; // return the list of modules as css string
  52.  
  53. list.toString = function toString() {
  54. return this.map(function (item) {
  55. var content = "";
  56. var needLayer = typeof item[5] !== "undefined";
  57.  
  58. if (item[4]) {
  59. content += "@supports (".concat(item[4], ") {");
  60. }
  61.  
  62. if (item[2]) {
  63. content += "@media ".concat(item[2], " {");
  64. }
  65.  
  66. if (needLayer) {
  67. content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
  68. }
  69.  
  70. content += cssWithMappingToString(item);
  71.  
  72. if (needLayer) {
  73. content += "}";
  74. }
  75.  
  76. if (item[2]) {
  77. content += "}";
  78. }
  79.  
  80. if (item[4]) {
  81. content += "}";
  82. }
  83.  
  84. return content;
  85. }).join("");
  86. }; // import a list of modules into the list
  87.  
  88.  
  89. list.i = function i(modules, media, dedupe, supports, layer) {
  90. if (typeof modules === "string") {
  91. modules = [[null, modules, undefined]];
  92. }
  93.  
  94. var alreadyImportedModules = {};
  95.  
  96. if (dedupe) {
  97. for (var k = 0; k < this.length; k++) {
  98. var id = this[k][0];
  99.  
  100. if (id != null) {
  101. alreadyImportedModules[id] = true;
  102. }
  103. }
  104. }
  105.  
  106. for (var _k = 0; _k < modules.length; _k++) {
  107. var item = [].concat(modules[_k]);
  108.  
  109. if (dedupe && alreadyImportedModules[item[0]]) {
  110. continue;
  111. }
  112.  
  113. if (typeof layer !== "undefined") {
  114. if (typeof item[5] === "undefined") {
  115. item[5] = layer;
  116. } else {
  117. item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
  118. item[5] = layer;
  119. }
  120. }
  121.  
  122. if (media) {
  123. if (!item[2]) {
  124. item[2] = media;
  125. } else {
  126. item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
  127. item[2] = media;
  128. }
  129. }
  130.  
  131. if (supports) {
  132. if (!item[4]) {
  133. item[4] = "".concat(supports);
  134. } else {
  135. item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
  136. item[4] = supports;
  137. }
  138. }
  139.  
  140. list.push(item);
  141. }
  142. };
  143.  
  144. return list;
  145. };
  146.  
  147. /***/ }),
  148.  
  149. /***/ 601:
  150. /***/ ((module) => {
  151.  
  152.  
  153.  
  154. module.exports = function (i) {
  155. return i[1];
  156. };
  157.  
  158. /***/ }),
  159.  
  160. /***/ 62:
  161. /***/ ((module) => {
  162.  
  163.  
  164.  
  165. var stylesInDOM = [];
  166.  
  167. function getIndexByIdentifier(identifier) {
  168. var result = -1;
  169.  
  170. for (var i = 0; i < stylesInDOM.length; i++) {
  171. if (stylesInDOM[i].identifier === identifier) {
  172. result = i;
  173. break;
  174. }
  175. }
  176.  
  177. return result;
  178. }
  179.  
  180. function modulesToDom(list, options) {
  181. var idCountMap = {};
  182. var identifiers = [];
  183.  
  184. for (var i = 0; i < list.length; i++) {
  185. var item = list[i];
  186. var id = options.base ? item[0] + options.base : item[0];
  187. var count = idCountMap[id] || 0;
  188. var identifier = "".concat(id, " ").concat(count);
  189. idCountMap[id] = count + 1;
  190. var indexByIdentifier = getIndexByIdentifier(identifier);
  191. var obj = {
  192. css: item[1],
  193. media: item[2],
  194. sourceMap: item[3],
  195. supports: item[4],
  196. layer: item[5]
  197. };
  198.  
  199. if (indexByIdentifier !== -1) {
  200. stylesInDOM[indexByIdentifier].references++;
  201. stylesInDOM[indexByIdentifier].updater(obj);
  202. } else {
  203. var updater = addElementStyle(obj, options);
  204. options.byIndex = i;
  205. stylesInDOM.splice(i, 0, {
  206. identifier: identifier,
  207. updater: updater,
  208. references: 1
  209. });
  210. }
  211.  
  212. identifiers.push(identifier);
  213. }
  214.  
  215. return identifiers;
  216. }
  217.  
  218. function addElementStyle(obj, options) {
  219. var api = options.domAPI(options);
  220. api.update(obj);
  221.  
  222. var updater = function updater(newObj) {
  223. if (newObj) {
  224. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
  225. return;
  226. }
  227.  
  228. api.update(obj = newObj);
  229. } else {
  230. api.remove();
  231. }
  232. };
  233.  
  234. return updater;
  235. }
  236.  
  237. module.exports = function (list, options) {
  238. options = options || {};
  239. list = list || [];
  240. var lastIdentifiers = modulesToDom(list, options);
  241. return function update(newList) {
  242. newList = newList || [];
  243.  
  244. for (var i = 0; i < lastIdentifiers.length; i++) {
  245. var identifier = lastIdentifiers[i];
  246. var index = getIndexByIdentifier(identifier);
  247. stylesInDOM[index].references--;
  248. }
  249.  
  250. var newLastIdentifiers = modulesToDom(newList, options);
  251.  
  252. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  253. var _identifier = lastIdentifiers[_i];
  254.  
  255. var _index = getIndexByIdentifier(_identifier);
  256.  
  257. if (stylesInDOM[_index].references === 0) {
  258. stylesInDOM[_index].updater();
  259.  
  260. stylesInDOM.splice(_index, 1);
  261. }
  262. }
  263.  
  264. lastIdentifiers = newLastIdentifiers;
  265. };
  266. };
  267.  
  268. /***/ }),
  269.  
  270. /***/ 793:
  271. /***/ ((module) => {
  272.  
  273.  
  274.  
  275. var memo = {};
  276. /* istanbul ignore next */
  277.  
  278. function getTarget(target) {
  279. if (typeof memo[target] === "undefined") {
  280. var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
  281.  
  282. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  283. try {
  284. // This will throw an exception if access to iframe is blocked
  285. // due to cross-origin restrictions
  286. styleTarget = styleTarget.contentDocument.head;
  287. } catch (e) {
  288. // istanbul ignore next
  289. styleTarget = null;
  290. }
  291. }
  292.  
  293. memo[target] = styleTarget;
  294. }
  295.  
  296. return memo[target];
  297. }
  298. /* istanbul ignore next */
  299.  
  300.  
  301. function insertBySelector(insert, style) {
  302. var target = getTarget(insert);
  303.  
  304. if (!target) {
  305. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  306. }
  307.  
  308. target.appendChild(style);
  309. }
  310.  
  311. module.exports = insertBySelector;
  312.  
  313. /***/ }),
  314.  
  315. /***/ 173:
  316. /***/ ((module) => {
  317.  
  318.  
  319.  
  320. /* istanbul ignore next */
  321. function insertStyleElement(options) {
  322. var element = document.createElement("style");
  323. options.setAttributes(element, options.attributes);
  324. options.insert(element, options.options);
  325. return element;
  326. }
  327.  
  328. module.exports = insertStyleElement;
  329.  
  330. /***/ }),
  331.  
  332. /***/ 892:
  333. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  334.  
  335.  
  336.  
  337. /* istanbul ignore next */
  338. function setAttributesWithoutAttributes(styleElement) {
  339. var nonce = true ? __webpack_require__.nc : 0;
  340.  
  341. if (nonce) {
  342. styleElement.setAttribute("nonce", nonce);
  343. }
  344. }
  345.  
  346. module.exports = setAttributesWithoutAttributes;
  347.  
  348. /***/ }),
  349.  
  350. /***/ 36:
  351. /***/ ((module) => {
  352.  
  353.  
  354.  
  355. /* istanbul ignore next */
  356. function apply(styleElement, options, obj) {
  357. var css = "";
  358.  
  359. if (obj.supports) {
  360. css += "@supports (".concat(obj.supports, ") {");
  361. }
  362.  
  363. if (obj.media) {
  364. css += "@media ".concat(obj.media, " {");
  365. }
  366.  
  367. var needLayer = typeof obj.layer !== "undefined";
  368.  
  369. if (needLayer) {
  370. css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
  371. }
  372.  
  373. css += obj.css;
  374.  
  375. if (needLayer) {
  376. css += "}";
  377. }
  378.  
  379. if (obj.media) {
  380. css += "}";
  381. }
  382.  
  383. if (obj.supports) {
  384. css += "}";
  385. }
  386.  
  387. var sourceMap = obj.sourceMap;
  388.  
  389. if (sourceMap && typeof btoa !== "undefined") {
  390. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  391. } // For old IE
  392.  
  393. /* istanbul ignore if */
  394.  
  395.  
  396. options.styleTagTransform(css, styleElement, options.options);
  397. }
  398.  
  399. function removeStyleElement(styleElement) {
  400. // istanbul ignore if
  401. if (styleElement.parentNode === null) {
  402. return false;
  403. }
  404.  
  405. styleElement.parentNode.removeChild(styleElement);
  406. }
  407. /* istanbul ignore next */
  408.  
  409.  
  410. function domAPI(options) {
  411. var styleElement = options.insertStyleElement(options);
  412. return {
  413. update: function update(obj) {
  414. apply(styleElement, options, obj);
  415. },
  416. remove: function remove() {
  417. removeStyleElement(styleElement);
  418. }
  419. };
  420. }
  421.  
  422. module.exports = domAPI;
  423.  
  424. /***/ }),
  425.  
  426. /***/ 464:
  427. /***/ ((module) => {
  428.  
  429.  
  430.  
  431. /* istanbul ignore next */
  432. function styleTagTransform(css, styleElement) {
  433. if (styleElement.styleSheet) {
  434. styleElement.styleSheet.cssText = css;
  435. } else {
  436. while (styleElement.firstChild) {
  437. styleElement.removeChild(styleElement.firstChild);
  438. }
  439.  
  440. styleElement.appendChild(document.createTextNode(css));
  441. }
  442. }
  443.  
  444. module.exports = styleTagTransform;
  445.  
  446. /***/ })
  447.  
  448. /******/ });
  449. /************************************************************************/
  450. /******/ // The module cache
  451. /******/ var __webpack_module_cache__ = {};
  452. /******/
  453. /******/ // The require function
  454. /******/ function __webpack_require__(moduleId) {
  455. /******/ // Check if module is in cache
  456. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  457. /******/ if (cachedModule !== undefined) {
  458. /******/ return cachedModule.exports;
  459. /******/ }
  460. /******/ // Create a new module (and put it into the cache)
  461. /******/ var module = __webpack_module_cache__[moduleId] = {
  462. /******/ id: moduleId,
  463. /******/ // no module.loaded needed
  464. /******/ exports: {}
  465. /******/ };
  466. /******/
  467. /******/ // Execute the module function
  468. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  469. /******/
  470. /******/ // Return the exports of the module
  471. /******/ return module.exports;
  472. /******/ }
  473. /******/
  474. /************************************************************************/
  475. /******/ /* webpack/runtime/compat get default export */
  476. /******/ (() => {
  477. /******/ // getDefaultExport function for compatibility with non-harmony modules
  478. /******/ __webpack_require__.n = (module) => {
  479. /******/ var getter = module && module.__esModule ?
  480. /******/ () => (module['default']) :
  481. /******/ () => (module);
  482. /******/ __webpack_require__.d(getter, { a: getter });
  483. /******/ return getter;
  484. /******/ };
  485. /******/ })();
  486. /******/
  487. /******/ /* webpack/runtime/define property getters */
  488. /******/ (() => {
  489. /******/ // define getter functions for harmony exports
  490. /******/ __webpack_require__.d = (exports, definition) => {
  491. /******/ for(var key in definition) {
  492. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  493. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  494. /******/ }
  495. /******/ }
  496. /******/ };
  497. /******/ })();
  498. /******/
  499. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  500. /******/ (() => {
  501. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  502. /******/ })();
  503. /******/
  504. /************************************************************************/
  505. var __webpack_exports__ = {};
  506. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  507. (() => {
  508.  
  509. // EXTERNAL MODULE: ../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
  510. var injectStylesIntoStyleTag = __webpack_require__(62);
  511. var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
  512. // EXTERNAL MODULE: ../../node_modules/style-loader/dist/runtime/styleDomAPI.js
  513. var styleDomAPI = __webpack_require__(36);
  514. var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
  515. // EXTERNAL MODULE: ../../node_modules/style-loader/dist/runtime/insertBySelector.js
  516. var insertBySelector = __webpack_require__(793);
  517. var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
  518. // EXTERNAL MODULE: ../../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
  519. var setAttributesWithoutAttributes = __webpack_require__(892);
  520. var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
  521. // EXTERNAL MODULE: ../../node_modules/style-loader/dist/runtime/insertStyleElement.js
  522. var insertStyleElement = __webpack_require__(173);
  523. var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
  524. // EXTERNAL MODULE: ../../node_modules/style-loader/dist/runtime/styleTagTransform.js
  525. var styleTagTransform = __webpack_require__(464);
  526. var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
  527. // EXTERNAL MODULE: ../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./src/styles/index.scss
  528. var styles = __webpack_require__(737);
  529. ;// CONCATENATED MODULE: ./src/styles/index.scss
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541. var options = {};
  542.  
  543. options.styleTagTransform = (styleTagTransform_default());
  544. options.setAttributes = (setAttributesWithoutAttributes_default());
  545.  
  546. options.insert = insertBySelector_default().bind(null, "head");
  547.  
  548. options.domAPI = (styleDomAPI_default());
  549. options.insertStyleElement = (insertStyleElement_default());
  550.  
  551. var update = injectStylesIntoStyleTag_default()(styles/* default */.Z, options);
  552.  
  553.  
  554.  
  555.  
  556. /* harmony default export */ const src_styles = (styles/* default */.Z && styles/* default.locals */.Z.locals ? styles/* default.locals */.Z.locals : undefined);
  557.  
  558. ;// CONCATENATED MODULE: ./src/components/ui.js
  559. var dq = document.querySelector.bind(document);
  560.  
  561. function UI() {
  562. this.init();
  563. }
  564.  
  565. UI.prototype.init = function () {
  566. console.log("[info] 欢迎使用 [CSDN 绿化] 插件");
  567. };
  568.  
  569. UI.prototype.mounted = function () {
  570. this.body = document.body;
  571. };
  572.  
  573. UI.prototype.csdn = function () {
  574. this.body.classList.add("csdn");
  575.  
  576. if (window.location.href.includes("category")) {
  577. this.body.classList.add("category");
  578. }
  579.  
  580. this.blog_content = dq("#article_content");
  581.  
  582. if (this.blog_content) {
  583. this.blog_content.classList.add("markdown-body");
  584. }
  585.  
  586. this.ads = [".csdn-side-toolbar", "#asideHotArticle", "#asideArchive"];
  587. this.process();
  588. this.processCSDN();
  589. };
  590.  
  591. UI.prototype.process = function () {
  592. this.processRemoveAD();
  593. this.mode = "home";
  594.  
  595. if (this.blog_content) {
  596. this.mode = "article";
  597. } else {
  598. this.mode = "menu";
  599. }
  600.  
  601. this.body.classList.add(this.mode);
  602. };
  603.  
  604. UI.prototype.processRemoveAD = function () {
  605. if (this.ads && this.ads.length) {
  606. this.ads.forEach(function (selector) {
  607. var ad = dq(selector);
  608. console.log("[info] 去除广告", selector);
  609. if (ad) ad.parentElement.removeChild(ad);
  610. });
  611. }
  612. };
  613.  
  614. UI.prototype.processCSDN = function () {
  615. window.onload = function () {
  616. // 去除剪贴板劫持
  617. csdn.copyright && (csdn.copyright.textData = "");
  618.  
  619. try {
  620. Object.defineProperty(window, "articleType", {
  621. value: 0,
  622. writable: false,
  623. configurable: false
  624. });
  625. $("#csdn-toolbar").css("border-bottom", "2px solid #409eff");
  626. } catch (err) {} // 修复无法复制
  627.  
  628.  
  629. $("pre").css("user-select", "auto");
  630. $("code").css("user-select", "auto");
  631. $("blockquote").css("user-select", "auto"); // 免登录(不可用)复制
  632.  
  633. $(".hljs-button").removeClass("signin");
  634. $(".hljs-button").addClass("copy-button");
  635. $(".hljs-button").attr("onclick", "hljs.copyCode(event)");
  636. $(".hljs-button").attr("data-title", "免登录(不可用)复制");
  637. setInterval(function () {
  638. $(".hljs-button").attr("data-title", "免登录(不可用)复制");
  639. $(".passport-login-container").remove();
  640. }, 1000 / 60);
  641. };
  642. };
  643.  
  644. /* harmony default export */ const ui = (UI);
  645. ;// CONCATENATED MODULE: ./src/main.js
  646.  
  647.  
  648. var main_ui = new ui();
  649.  
  650. (function () {
  651. window.addEventListener("load", function () {
  652. init();
  653. });
  654. window.addEventListener("DOMContentLoaded", function () {
  655. init();
  656. });
  657. })();
  658.  
  659. var isInit = false;
  660.  
  661. function init() {
  662. if (isInit) return;
  663. isInit = true;
  664. main_ui.mounted();
  665. main_ui.csdn();
  666. document.body.style.display = "block";
  667. console.log("[info] Finshed");
  668. }
  669. })();
  670.  
  671. /******/ })()
  672. ;

QingJ © 2025

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