CSDN Greener

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

  1. // ==UserScript==
  2. // @name CSDN Greener
  3. // @version 0.0.13
  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. /***/ 667:
  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_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(885);
  26. /* harmony import */ var _node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  27. /* harmony import */ var _node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(118);
  28. /* harmony import */ var _node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  29. // Imports
  30.  
  31.  
  32. var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_pnpm_css_loader_6_8_1_webpack_5_88_2_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 #toolbarBox,.csdn #csdn-toolbar{height:0 !important;min-height:0 !important}.csdn .passport-login-container{display:none !important}.csdn #recommendAdBox,.csdn #mainBox>aside>div.box-shadow.mb8>div,.csdn .toolbar-menus.csdn-toolbar-fl,.csdn .toolbar-container-left,.csdn .toolbar-container-middle,.csdn .toolbar-container-right{display:none !important}.csdn .blog-footer-bottom .passport-login-tip-container{display:none !important}.csdn .user-profile-head .user-profile-head-banner{height:2rem !important}.csdn .toolbar-container{height:0 !important}.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 #btnMoreComment,.csdn.article #footerRightAds,.csdn.article #asideWriteGuide,.csdn.article #asideSearchArticle,.csdn.article #blogHuaweiyunAdvert,.csdn.article #blogColumnPayAdvert,.csdn.article .programmer1Box,.csdn.article .adsbygoogle iframe,.csdn.article .kind_person,.csdn.article .recommend-box,.csdn.article .recommend-right_aside .toolbar-advert{display:none !important}.csdn.article{min-width:900px}.csdn.article .main_father.clearfix.d-flex.justify-content-center{gap:16px}.csdn.article #mainBox{margin-right:0 !important}.csdn.article #mainBox .blog-content-box{margin-top:0}.csdn.article #rightAside{margin-left:0 !important}@media screen and (max-width: 1200px){.main_father.clearfix.d-flex.justify-content-center{display:flex;justify-content:center}#mainBox{width:auto}#mainBox main{float:none !important}.csdn.article #asidedirectory{display:none !important}}.csdn.article .template-box{margin-bottom:1em}.csdn.article #asidedirectory{position:fixed;top:.5rem}.csdn.article aside div.aside-box h3.aside-title{background-color:#fff}.csdn.article #groupfile.flex-column,.csdn.article #groupfile.flex-column .groupfile-div{max-height:calc(100vh - 1rem) !important}.csdn.article #asidedirectory #directory .group_item{max-height:calc(100vh - 5rem) !important}.csdn.article blockquote{margin:.5em !important;padding:1em !important;border-left:5px solid #005282 !important;background-color:#f4f4f4 !important;color:#1b1b1b !important}.hljs-ln.hundred{width:800px !important}@page{margin:0}body{margin:0}.sheet{margin:0;overflow:hidden;position:relative;box-sizing:border-box;page-break-after:always}body.A3 .sheet{width:297mm;height:419mm}body.A3.landscape .sheet{width:420mm;height:296mm}body.A4 .sheet{width:210mm;height:296mm}body.A4.landscape .sheet{width:297mm;height:209mm}body.A5 .sheet{width:148mm;height:209mm}body.A5.landscape .sheet{width:210mm;height:147mm}body.letter .sheet{width:216mm;height:279mm}body.letter.landscape .sheet{width:280mm;height:215mm}body.legal .sheet{width:216mm;height:356mm}body.legal.landscape .sheet{width:357mm;height:215mm}.sheet.padding-10mm{padding:10mm}.sheet.padding-15mm{padding:15mm}.sheet.padding-20mm{padding:20mm}.sheet.padding-25mm{padding:25mm}@media screen{body{background:#e0e0e0}.sheet{background:#fff;box-shadow:0 .5mm 2mm rgba(0,0,0,.3);margin:5mm auto}}@media print{body.A3.landscape{width:420mm}body.A3,body.A4.landscape{width:297mm}body.A4,body.A5.landscape{width:210mm}body.A5{width:148mm}body.letter,body.legal{width:216mm}body.letter.landscape{width:280mm}body.legal.landscape{width:357mm}}`, ""]);
  35. // Exports
  36. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  37.  
  38.  
  39. /***/ }),
  40.  
  41. /***/ 118:
  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 = [];
  52.  
  53. // return the list of modules as css string
  54. list.toString = function toString() {
  55. return this.map(function (item) {
  56. var content = "";
  57. var needLayer = typeof item[5] !== "undefined";
  58. if (item[4]) {
  59. content += "@supports (".concat(item[4], ") {");
  60. }
  61. if (item[2]) {
  62. content += "@media ".concat(item[2], " {");
  63. }
  64. if (needLayer) {
  65. content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
  66. }
  67. content += cssWithMappingToString(item);
  68. if (needLayer) {
  69. content += "}";
  70. }
  71. if (item[2]) {
  72. content += "}";
  73. }
  74. if (item[4]) {
  75. content += "}";
  76. }
  77. return content;
  78. }).join("");
  79. };
  80.  
  81. // import a list of modules into the list
  82. list.i = function i(modules, media, dedupe, supports, layer) {
  83. if (typeof modules === "string") {
  84. modules = [[null, modules, undefined]];
  85. }
  86. var alreadyImportedModules = {};
  87. if (dedupe) {
  88. for (var k = 0; k < this.length; k++) {
  89. var id = this[k][0];
  90. if (id != null) {
  91. alreadyImportedModules[id] = true;
  92. }
  93. }
  94. }
  95. for (var _k = 0; _k < modules.length; _k++) {
  96. var item = [].concat(modules[_k]);
  97. if (dedupe && alreadyImportedModules[item[0]]) {
  98. continue;
  99. }
  100. if (typeof layer !== "undefined") {
  101. if (typeof item[5] === "undefined") {
  102. item[5] = layer;
  103. } else {
  104. item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
  105. item[5] = layer;
  106. }
  107. }
  108. if (media) {
  109. if (!item[2]) {
  110. item[2] = media;
  111. } else {
  112. item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
  113. item[2] = media;
  114. }
  115. }
  116. if (supports) {
  117. if (!item[4]) {
  118. item[4] = "".concat(supports);
  119. } else {
  120. item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
  121. item[4] = supports;
  122. }
  123. }
  124. list.push(item);
  125. }
  126. };
  127. return list;
  128. };
  129.  
  130. /***/ }),
  131.  
  132. /***/ 885:
  133. /***/ ((module) => {
  134.  
  135.  
  136.  
  137. module.exports = function (i) {
  138. return i[1];
  139. };
  140.  
  141. /***/ }),
  142.  
  143. /***/ 886:
  144. /***/ ((module) => {
  145.  
  146.  
  147.  
  148. var stylesInDOM = [];
  149. function getIndexByIdentifier(identifier) {
  150. var result = -1;
  151. for (var i = 0; i < stylesInDOM.length; i++) {
  152. if (stylesInDOM[i].identifier === identifier) {
  153. result = i;
  154. break;
  155. }
  156. }
  157. return result;
  158. }
  159. function modulesToDom(list, options) {
  160. var idCountMap = {};
  161. var identifiers = [];
  162. for (var i = 0; i < list.length; i++) {
  163. var item = list[i];
  164. var id = options.base ? item[0] + options.base : item[0];
  165. var count = idCountMap[id] || 0;
  166. var identifier = "".concat(id, " ").concat(count);
  167. idCountMap[id] = count + 1;
  168. var indexByIdentifier = getIndexByIdentifier(identifier);
  169. var obj = {
  170. css: item[1],
  171. media: item[2],
  172. sourceMap: item[3],
  173. supports: item[4],
  174. layer: item[5]
  175. };
  176. if (indexByIdentifier !== -1) {
  177. stylesInDOM[indexByIdentifier].references++;
  178. stylesInDOM[indexByIdentifier].updater(obj);
  179. } else {
  180. var updater = addElementStyle(obj, options);
  181. options.byIndex = i;
  182. stylesInDOM.splice(i, 0, {
  183. identifier: identifier,
  184. updater: updater,
  185. references: 1
  186. });
  187. }
  188. identifiers.push(identifier);
  189. }
  190. return identifiers;
  191. }
  192. function addElementStyle(obj, options) {
  193. var api = options.domAPI(options);
  194. api.update(obj);
  195. var updater = function updater(newObj) {
  196. if (newObj) {
  197. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
  198. return;
  199. }
  200. api.update(obj = newObj);
  201. } else {
  202. api.remove();
  203. }
  204. };
  205. return updater;
  206. }
  207. module.exports = function (list, options) {
  208. options = options || {};
  209. list = list || [];
  210. var lastIdentifiers = modulesToDom(list, options);
  211. return function update(newList) {
  212. newList = newList || [];
  213. for (var i = 0; i < lastIdentifiers.length; i++) {
  214. var identifier = lastIdentifiers[i];
  215. var index = getIndexByIdentifier(identifier);
  216. stylesInDOM[index].references--;
  217. }
  218. var newLastIdentifiers = modulesToDom(newList, options);
  219. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  220. var _identifier = lastIdentifiers[_i];
  221. var _index = getIndexByIdentifier(_identifier);
  222. if (stylesInDOM[_index].references === 0) {
  223. stylesInDOM[_index].updater();
  224. stylesInDOM.splice(_index, 1);
  225. }
  226. }
  227. lastIdentifiers = newLastIdentifiers;
  228. };
  229. };
  230.  
  231. /***/ }),
  232.  
  233. /***/ 122:
  234. /***/ ((module) => {
  235.  
  236.  
  237.  
  238. var memo = {};
  239.  
  240. /* istanbul ignore next */
  241. function getTarget(target) {
  242. if (typeof memo[target] === "undefined") {
  243. var styleTarget = document.querySelector(target);
  244.  
  245. // Special case to return head of iframe instead of iframe itself
  246. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  247. try {
  248. // This will throw an exception if access to iframe is blocked
  249. // due to cross-origin restrictions
  250. styleTarget = styleTarget.contentDocument.head;
  251. } catch (e) {
  252. // istanbul ignore next
  253. styleTarget = null;
  254. }
  255. }
  256. memo[target] = styleTarget;
  257. }
  258. return memo[target];
  259. }
  260.  
  261. /* istanbul ignore next */
  262. function insertBySelector(insert, style) {
  263. var target = getTarget(insert);
  264. if (!target) {
  265. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  266. }
  267. target.appendChild(style);
  268. }
  269. module.exports = insertBySelector;
  270.  
  271. /***/ }),
  272.  
  273. /***/ 611:
  274. /***/ ((module) => {
  275.  
  276.  
  277.  
  278. /* istanbul ignore next */
  279. function insertStyleElement(options) {
  280. var element = document.createElement("style");
  281. options.setAttributes(element, options.attributes);
  282. options.insert(element, options.options);
  283. return element;
  284. }
  285. module.exports = insertStyleElement;
  286.  
  287. /***/ }),
  288.  
  289. /***/ 791:
  290. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  291.  
  292.  
  293.  
  294. /* istanbul ignore next */
  295. function setAttributesWithoutAttributes(styleElement) {
  296. var nonce = true ? __webpack_require__.nc : 0;
  297. if (nonce) {
  298. styleElement.setAttribute("nonce", nonce);
  299. }
  300. }
  301. module.exports = setAttributesWithoutAttributes;
  302.  
  303. /***/ }),
  304.  
  305. /***/ 788:
  306. /***/ ((module) => {
  307.  
  308.  
  309.  
  310. /* istanbul ignore next */
  311. function apply(styleElement, options, obj) {
  312. var css = "";
  313. if (obj.supports) {
  314. css += "@supports (".concat(obj.supports, ") {");
  315. }
  316. if (obj.media) {
  317. css += "@media ".concat(obj.media, " {");
  318. }
  319. var needLayer = typeof obj.layer !== "undefined";
  320. if (needLayer) {
  321. css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
  322. }
  323. css += obj.css;
  324. if (needLayer) {
  325. css += "}";
  326. }
  327. if (obj.media) {
  328. css += "}";
  329. }
  330. if (obj.supports) {
  331. css += "}";
  332. }
  333. var sourceMap = obj.sourceMap;
  334. if (sourceMap && typeof btoa !== "undefined") {
  335. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  336. }
  337.  
  338. // For old IE
  339. /* istanbul ignore if */
  340. options.styleTagTransform(css, styleElement, options.options);
  341. }
  342. function removeStyleElement(styleElement) {
  343. // istanbul ignore if
  344. if (styleElement.parentNode === null) {
  345. return false;
  346. }
  347. styleElement.parentNode.removeChild(styleElement);
  348. }
  349.  
  350. /* istanbul ignore next */
  351. function domAPI(options) {
  352. if (typeof document === "undefined") {
  353. return {
  354. update: function update() {},
  355. remove: function remove() {}
  356. };
  357. }
  358. var styleElement = options.insertStyleElement(options);
  359. return {
  360. update: function update(obj) {
  361. apply(styleElement, options, obj);
  362. },
  363. remove: function remove() {
  364. removeStyleElement(styleElement);
  365. }
  366. };
  367. }
  368. module.exports = domAPI;
  369.  
  370. /***/ }),
  371.  
  372. /***/ 671:
  373. /***/ ((module) => {
  374.  
  375.  
  376.  
  377. /* istanbul ignore next */
  378. function styleTagTransform(css, styleElement) {
  379. if (styleElement.styleSheet) {
  380. styleElement.styleSheet.cssText = css;
  381. } else {
  382. while (styleElement.firstChild) {
  383. styleElement.removeChild(styleElement.firstChild);
  384. }
  385. styleElement.appendChild(document.createTextNode(css));
  386. }
  387. }
  388. module.exports = styleTagTransform;
  389.  
  390. /***/ })
  391.  
  392. /******/ });
  393. /************************************************************************/
  394. /******/ // The module cache
  395. /******/ var __webpack_module_cache__ = {};
  396. /******/
  397. /******/ // The require function
  398. /******/ function __webpack_require__(moduleId) {
  399. /******/ // Check if module is in cache
  400. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  401. /******/ if (cachedModule !== undefined) {
  402. /******/ return cachedModule.exports;
  403. /******/ }
  404. /******/ // Create a new module (and put it into the cache)
  405. /******/ var module = __webpack_module_cache__[moduleId] = {
  406. /******/ id: moduleId,
  407. /******/ // no module.loaded needed
  408. /******/ exports: {}
  409. /******/ };
  410. /******/
  411. /******/ // Execute the module function
  412. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  413. /******/
  414. /******/ // Return the exports of the module
  415. /******/ return module.exports;
  416. /******/ }
  417. /******/
  418. /************************************************************************/
  419. /******/ /* webpack/runtime/compat get default export */
  420. /******/ (() => {
  421. /******/ // getDefaultExport function for compatibility with non-harmony modules
  422. /******/ __webpack_require__.n = (module) => {
  423. /******/ var getter = module && module.__esModule ?
  424. /******/ () => (module['default']) :
  425. /******/ () => (module);
  426. /******/ __webpack_require__.d(getter, { a: getter });
  427. /******/ return getter;
  428. /******/ };
  429. /******/ })();
  430. /******/
  431. /******/ /* webpack/runtime/define property getters */
  432. /******/ (() => {
  433. /******/ // define getter functions for harmony exports
  434. /******/ __webpack_require__.d = (exports, definition) => {
  435. /******/ for(var key in definition) {
  436. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  437. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  438. /******/ }
  439. /******/ }
  440. /******/ };
  441. /******/ })();
  442. /******/
  443. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  444. /******/ (() => {
  445. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  446. /******/ })();
  447. /******/
  448. /******/ /* webpack/runtime/nonce */
  449. /******/ (() => {
  450. /******/ __webpack_require__.nc = undefined;
  451. /******/ })();
  452. /******/
  453. /************************************************************************/
  454. var __webpack_exports__ = {};
  455. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  456. (() => {
  457.  
  458. // EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
  459. var injectStylesIntoStyleTag = __webpack_require__(886);
  460. var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
  461. // EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/styleDomAPI.js
  462. var styleDomAPI = __webpack_require__(788);
  463. var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
  464. // EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/insertBySelector.js
  465. var insertBySelector = __webpack_require__(122);
  466. var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
  467. // EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
  468. var setAttributesWithoutAttributes = __webpack_require__(791);
  469. var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
  470. // EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/insertStyleElement.js
  471. var insertStyleElement = __webpack_require__(611);
  472. var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
  473. // EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/styleTagTransform.js
  474. var styleTagTransform = __webpack_require__(671);
  475. var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
  476. // EXTERNAL MODULE: ../../node_modules/.pnpm/css-loader@6.8.1_webpack@5.88.2/node_modules/css-loader/dist/cjs.js!../../node_modules/.pnpm/sass-loader@12.6.0_sass@1.69.3+webpack@5.88.2/node_modules/sass-loader/dist/cjs.js!./src/styles/index.scss
  477. var styles = __webpack_require__(667);
  478. ;// CONCATENATED MODULE: ./src/styles/index.scss
  479.  
  480.  
  481. var options = {};
  482.  
  483. options.styleTagTransform = (styleTagTransform_default());
  484. options.setAttributes = (setAttributesWithoutAttributes_default());
  485.  
  486. options.insert = insertBySelector_default().bind(null, "head");
  487. options.domAPI = (styleDomAPI_default());
  488. options.insertStyleElement = (insertStyleElement_default());
  489.  
  490. var update = injectStylesIntoStyleTag_default()(styles/* default */.Z, options);
  491.  
  492.  
  493.  
  494.  
  495. /* harmony default export */ const src_styles = (styles/* default */.Z && styles/* default */.Z.locals ? styles/* default */.Z.locals : undefined);
  496.  
  497. ;// CONCATENATED MODULE: ./src/utils/index.js
  498. function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
  499. var injection = function injection() {
  500. !function (e) {
  501. "use strict";
  502.  
  503. function t() {
  504. return !!window.navigator.userAgent.toLowerCase().match(/(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)/i);
  505. }
  506. function n() {
  507. return !!window.navigator.userAgent.toLowerCase().match(/(csdn)/i);
  508. }
  509. function o(e) {
  510. for (var t = document.cookie.split("; "), n = 0; n < t.length; n++) {
  511. var o = t[n].split("=");
  512. if (e == o[0]) return o[1];
  513. }
  514. return null;
  515. }
  516. function i(e) {
  517. var t = e.target || e.srcElement,
  518. n = document.documentElement.scrollTop;
  519. if (t.className.indexOf('hljs-button') > -1) {
  520. e.preventDefault();
  521. var o = document.getElementById("hljs-copy-el");
  522. o || (o = document.createElement("textarea"), o.style.position = "absolute", o.style.left = "-9999px", o.style.top = n + "px", o.id = "hljs-copy-el", document.body.appendChild(o)), o.textContent = e.currentTarget.innerText.replace(/[\u00A0]/gi, " "), f($(e.currentTarget.parentNode).attr("data-index")), a("#hljs-copy-el");
  523. try {
  524. var i = document.execCommand("copy");
  525. o.remove(), t.dataset.title = i ? b : y, i && setTimeout(function () {
  526. t.dataset.title = x;
  527. }, 3e3);
  528. } catch (r) {
  529. t.dataset.title = y;
  530. }
  531. }
  532. }
  533. function r(e) {
  534. var t = e.target || e.srcElement,
  535. n = document.documentElement.scrollTop;
  536. if (t.className.indexOf("hljs-button") > -1) {
  537. e.preventDefault();
  538. var o = document.getElementById("hljs-copy-el");
  539. o || (o = document.createElement("textarea"), o.style.position = "absolute", o.style.left = "-9999px", o.style.top = n + "px", o.id = "hljs-copy-el", document.body.appendChild(o)), o.textContent = e.currentTarget.parentNode.innerText.replace(/[\u00A0]/gi, " "), f($(e.currentTarget.parentNode).attr("data-index")), a("#hljs-copy-el");
  540. try {
  541. var i = document.execCommand("copy");
  542. o.remove(), t.dataset.title = i ? b : y, i && setTimeout(function () {
  543. t.dataset.title = x;
  544. }, 3e3);
  545. } catch (r) {
  546. t.dataset.title = y;
  547. }
  548. }
  549. }
  550. function a(e) {
  551. if (e = "string" == typeof e ? document.querySelector(e) : e, navigator.userAgent.match(/ipad|ipod|iphone/i)) {
  552. var t = e.contentEditable,
  553. n = e.readOnly;
  554. e.contentEditable = !0, e.readOnly = !0;
  555. var o = document.createRange();
  556. o.selectNodeContents(e);
  557. var i = window.getSelection();
  558. i.removeAllRanges(), i.addRange(o), e.setSelectionRange(0, 999999), e.contentEditable = t, e.readOnly = n;
  559. } else e.select();
  560. }
  561. function c() {
  562. var e = "z-index: 20;";
  563. n() && (e = "z-index: 100002;");
  564. var t = document.createElement("style");
  565. t.type = "text/css", window.navigator.userAgent.toLowerCase().match(/(csdn)/i) && isShowCodeFull ? t.innerHTML = ["pre{position: relative}", "pre:hover .code-full-screen{display:block !important;}", ".code-full-screen{", "display: none !important;", "position: absolute;", "right: 4px;", "top: 4px;", "width: 24px !important;", "height: 24px !important;", "margin: 4px !important;", e, "}", "pre:hover .{0}{display: block}", ".{0}{", "display: none;", "position: absolute;", "right: 34px;", "top: 4px;", "font-size: 12px;", "color: #ffffff;", "background-color: #9999AA;", "width:58px;", "text-align: center;", "padding:2px 0;", "margin: 4px !important;", "border-radius: 4px;", e, "cursor: pointer;", " box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.05);", "}", ".{0}:after{", "content: attr(data-title)", "}", "code .{0}{", "margin: 2px 8px;", "}"].join("").format(v) : t.innerHTML = ["pre{position: relative}", "pre:hover .code-full-screen{display:none !important;}", ".code-full-screen{", "display: none !important;", "position: absolute;", "right: 4px;", "top: 3px;", "width: 24px !important;", "height: 24px !important;", "margin: 4px !important;", e, "}", "pre:hover .{0}{display: block}", ".{0}{", "display: none;", "position: absolute;", "right: 4px;", "top: 4px;", "font-size: 12px;", "color: #ffffff;", "background-color: #9999AA;", "width:58px;", "text-align: center;", "padding:2px 0;", e, "margin: 8px;", "border-radius: 4px;", "cursor: pointer;", " box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.05);", "}", ".{0}:after{", "content: attr(data-title)", "}", "code .{0}{", "margin: 2px 8px;", "}"].join("").format(v), document.getElementsByTagName("head")[0].appendChild(t);
  566. }
  567. function d() {
  568. "complete" === document.readyState ? l() : e.addEventListener("DOMContentLoaded", l);
  569. }
  570. function s(e) {
  571. if (!$(this).hasClass("active")) {
  572. if (!o("UserName")) return window.csdn.loginBox.show({
  573. spm: "1001.2101.3001.10011"
  574. }), void window.csdn.report.reportClick({
  575. spm: "3001.10011"
  576. });
  577. window.csdn.report.reportClick({
  578. spm: "3001.10012"
  579. });
  580. try {
  581. var t = e.currentTarget.parentNode.innerText;
  582. t = t.replaceAll("\n", "");
  583. var n = $(".annotation-boxshadow").data("isblack"),
  584. i = $(this).parents("pre").data("index") || "0",
  585. r = !0;
  586. $(".i-ai-code-bottom").hide(), codeMaxSize - t.length <= 0 && (r = !1), $(".annotation-content").attr("data-num", i), $("#annotation-iframe")[0].contentWindow.postMessage({
  587. type: "blog-code-sin",
  588. isblack: n,
  589. content: t,
  590. lengthFlag: r
  591. }, "*"), $(".annotation-boxshadow").show(), $(".annotation-btn .annotation-def").show(), $(".annotation-btn .annotation-active").hide(), $(".annotation-btn").removeClass("active");
  592. } catch (a) {
  593. console.error("CopyButton error: ", a);
  594. }
  595. }
  596. }
  597. function p() {
  598. try {
  599. var e,
  600. t = '<div class="code-annotation" data-title="一键注释"></div>';
  601. if (overCost || !canRead) return;
  602. unUseCount <= 0 && o("UserName") && (t = '<div class="code-annotation active" data-title="一键注释"><div class="code-annotation-mask" data-title="今日免费次数已用完"></div></div>'), "ckeditor" == C ? (e = $("code.hljs"), $("code.hljs").parent().each(function (e, n) {
  603. n && (n.innerHTML = n.innerHTML + t);
  604. })) : (e = $("pre code"), e.each(function (e, n) {
  605. n && (n.innerHTML = n.innerHTML + t);
  606. })), $(document).on("click", "pre .code-annotation", s);
  607. var n = "3001.10012";
  608. o("UserName") || (n = "3001.10011"), window.csdn.report && "function" == typeof window.csdn.report.reportView && window.csdn.report.reportView({
  609. spm: n
  610. });
  611. } catch (i) {
  612. console.error("CopyButton error: ", i);
  613. }
  614. }
  615. function l() {
  616. try {
  617. var e;
  618. if ("ckeditor" == C) {
  619. e = document.querySelectorAll("code.hljs");
  620. for (var i in e) e.hasOwnProperty(i) && u(e[i].parentNode);
  621. } else {
  622. e = A;
  623. for (var i in e) e.hasOwnProperty(i) && u(e[i]);
  624. }
  625. t() || n() || ($("#annotation-iframe").length > 0 && o("UserName") ? $("#annotation-iframe").on("load", function () {
  626. p();
  627. }) : p());
  628. } catch (r) {
  629. console.error("CopyButton error: ", r);
  630. }
  631. }
  632. function m(e) {
  633. var i = e.target || e.srcElement;
  634. i.className.indexOf(v) > -1 && (n() ? window.location.href = "https://passport.csdn.net/account/login?ref=codecopy" : t() ? toobarFlag(20, 21) ? $(".ab-app-shadowbox").show() : window.csdn.loginBox.show({
  635. spm: "1001.2101.3001.7759"
  636. }) : o("UserName") || window.csdn.loginBox.show({
  637. spm: "1001.2101.3001.4334"
  638. }));
  639. }
  640. function u(e) {
  641. var t = "";
  642. if ("object" == _typeof(e) && null !== e) {
  643. var n = ".signin(event)",
  644. o = "hljs",
  645. i = ".copyCode(event)";
  646. "mdeditor" === C && (o = "mdcp"), i = o + i, j && (i = o + n, t = 'data-report-click=\'{"spm":"1001.2101.3001.4334"}\''), window.navigator.userAgent.toLowerCase().match(/(csdn)/i) && isShowCodeFull ? e.innerHTML = e.innerHTML + ('<img class="code-full-screen app_remove_content no-enlarge-img" src="' + blogStaticHost + 'dist/app/img/codeAmplify.png"><div class="{0} {2}" data-title="{1}" ' + t + "></div>").format(v, x, k) : e.innerHTML = e.innerHTML + ('<div class="{0} {2}" data-title="{1}" ' + t + "></div>").format(v, x, k), "登录(不可用)复制" == x && $(".hljs-button").addClass("active"), "hljs" === o ? e.querySelector(".hljs-button").setAttribute("onclick", i) : (e.setAttribute("onclick", i), e.style.position = "unset");
  647. }
  648. }
  649. function f(e) {
  650. var t = "1001.2101.3001.4259",
  651. n = JSON.stringify({
  652. codeId: e
  653. });
  654. if (window.csdn.report && "function" == typeof window.csdn.report.reportClick) window.csdn.report.reportClick({
  655. spm: t,
  656. extra: n
  657. });else if (window.isApp) {
  658. var o = {
  659. spm: t,
  660. extra: n
  661. },
  662. i = {
  663. trackingInfo: JSON.stringify(o)
  664. };
  665. g && window.jsCallBackListener.csdntrackclick(JSON.stringify(i)), h && window.webkit.messageHandlers.csdntrackclick.postMessage(JSON.stringify(i));
  666. }
  667. }
  668. window.copyCode = r;
  669. if (window.ActiveXObject || "ActiveXObject" in window) return !1;
  670. var w = navigator.userAgent,
  671. g = w.indexOf("Android") > -1 || w.indexOf("Adr") > -1,
  672. h = !!w.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
  673. v = "hljs-button",
  674. x = "复制",
  675. y = "复制失败",
  676. b = "已复制",
  677. C = void 0,
  678. k = "",
  679. j = !1;
  680. n() || o("UserName") || (j = !0), j && (x = "登录(不可用)复制", k = "signin"), $("#content_views").find("pre").each(function (e, t) {
  681. $(t).attr("data-index", e);
  682. }), String.prototype.format = String.prototype.f = function () {
  683. var e = arguments;
  684. return !!this && this.replace(/\{(\d+)\}/g, function (t, n) {
  685. return e[n] ? e[n] : t;
  686. });
  687. };
  688. var A = document.querySelectorAll("pre code");
  689. document.querySelectorAll("div.htmledit_views").length > 0 ? (e.hljs.initCopyButtonOnLoad = d, e.hljs.addCopyButton = u, e.hljs.copyCode = r, e.hljs.signin = m, c(), C = "ckeditor") : A.length > 0 && (window.mdcp ? window.mdcp : window.mdcp = {}, window.mdcp.copyCode = i, window.mdcp.signin = m, d(), c(), C = "mdeditor"), $("#content_views").on("copy", function (e) {
  690. if (!n()) {
  691. var o = t() ? "3001.10057" : "3001.10056";
  692. window.csdn.report.reportClick({
  693. spm: o
  694. });
  695. }
  696. });
  697. }(window);
  698. };
  699. ;// CONCATENATED MODULE: ./src/components/ui.js
  700.  
  701. var dq = document.querySelector.bind(document);
  702. var timer = null;
  703. var copyCodeGreen = function copyCodeGreen(event) {
  704. console.log('copy do');
  705. $(".hljs-button").removeClass("success");
  706. try {
  707. window.copyCode(event);
  708. console.log('copy success');
  709. $(event.target).addClass("success");
  710. } catch (error) {
  711. console.log('copy failure', error);
  712. }
  713. clearTimeout(timer);
  714. timer = setTimeout(function () {
  715. $(".hljs-button").removeClass("success");
  716. }, 3000);
  717. };
  718. function UI() {
  719. this.init();
  720. }
  721. UI.prototype.init = function () {
  722. console.log("[info] 欢迎使用 [CSDN 绿化] 插件");
  723. };
  724. UI.prototype.mounted = function () {
  725. this.body = document.body;
  726. };
  727. UI.prototype.csdn = function () {
  728. this.body.classList.add("csdn");
  729. this.mode = "home";
  730. this.blog_content = dq("#article_content");
  731. if (this.blog_content) {
  732. this.blog_content.classList.add("markdown-body");
  733. this.mode = "article";
  734. } else if (window.location.href.includes("category")) {
  735. this.mode = "category";
  736. } else {
  737. this.mode = "menu";
  738. }
  739. this.body.classList.add(this.mode);
  740. this.ads = [".csdn-side-toolbar", "#asideHotArticle", "#asideArchive", ".passport-login-mark"];
  741. this.process();
  742. };
  743. UI.prototype.process = function () {
  744. this.processRemoveAD();
  745. this.processClipboard();
  746. };
  747. UI.prototype.processRemoveAD = function () {
  748. if (this.ads && this.ads.length) {
  749. this.ads.forEach(function (selector) {
  750. var ad = dq(selector);
  751. console.log("[info] 去除广告", selector);
  752. if (ad) ad.parentElement.removeChild(ad);
  753. });
  754. }
  755. };
  756. UI.prototype.processClipboard = function () {
  757. injection();
  758.  
  759. // 去除剪贴板劫持
  760. try {
  761. Object.defineProperty(window, "articleType", {
  762. value: 0,
  763. writable: false,
  764. configurable: false
  765. });
  766. $("#csdn-toolbar").css("border-bottom", "2px solid #4abf8a");
  767. } catch (err) {
  768. $("#csdn-toolbar").css("border-bottom", "2px solid #f56c6c");
  769. }
  770. // 修复无法复制
  771. $("pre").css("user-select", "auto");
  772. $("code").css("user-select", "auto");
  773. $("blockquote").css("user-select", "auto");
  774. // 拦截登录(不可用)
  775. $(".hljs-button").removeClass("signin");
  776. $(".hljs-button").removeAttr("data-report-click");
  777. $(".hljs").removeAttr("onclick");
  778. $(".hljs-button").removeAttr("onclick");
  779. $(".hljs-button").css("font-size", "12px");
  780. // 点击复制
  781. var buttons = document.getElementsByClassName("hljs-button");
  782. Array.from(buttons).forEach(function (button) {
  783. button.onclick = copyCodeGreen;
  784. });
  785. var alwaysDo = function alwaysDo() {
  786. if (window.csdn && csdn.copyright) {
  787. csdn.copyright.textData = "";
  788. csdn.copyright.htmlData = "";
  789. }
  790. $(".hljs-button").attr("data-title", "免登录(不可用)复制");
  791. $(".hljs-button").css("background-color", "#409eff");
  792. $(".hljs-button.success").attr("data-title", "复制成功!");
  793. $(".hljs-button.success").css("background-color", "#4abf8a");
  794. window.requestAnimationFrame(alwaysDo);
  795. };
  796. window.requestAnimationFrame(alwaysDo);
  797. };
  798. /* harmony default export */ const ui = (UI);
  799. ;// CONCATENATED MODULE: ./src/main.js
  800.  
  801.  
  802. var isInit = false;
  803. var main_ui = new ui();
  804. (function () {
  805. window.addEventListener("load", function () {
  806. init();
  807. });
  808. })();
  809. function init() {
  810. if (isInit) return;
  811. isInit = true;
  812. main_ui.mounted();
  813. main_ui.csdn();
  814. document.body.style.display = "block";
  815. console.log("[info] Finshed");
  816. }
  817. })();
  818.  
  819. /******/ })()
  820. ;

QingJ © 2025

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