// ==UserScript==
// @name CSDN Greener
// @version 0.0.13
// @description CSDN 专杀,广告统统滚开,内容样式统一,我不要你觉得,我就要我觉得
// @author gausszhou@qq.com
// @namespace gausszhou
// @grant none
// @run-at document-start
// @license MIT
// @icon https://www.gausszhou.top/favicon.ico
// @include *://*.csdn.net/*
// @include *://csdn.net/*
// ==/UserScript==
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 667:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Z: () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* 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);
/* 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__);
/* 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);
/* 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__);
// Imports
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()));
// Module
___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}}`, ""]);
// Exports
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
/***/ }),
/***/ 118:
/***/ ((module) => {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function (cssWithMappingToString) {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = "";
var needLayer = typeof item[5] !== "undefined";
if (item[4]) {
content += "@supports (".concat(item[4], ") {");
}
if (item[2]) {
content += "@media ".concat(item[2], " {");
}
if (needLayer) {
content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
}
content += cssWithMappingToString(item);
if (needLayer) {
content += "}";
}
if (item[2]) {
content += "}";
}
if (item[4]) {
content += "}";
}
return content;
}).join("");
};
// import a list of modules into the list
list.i = function i(modules, media, dedupe, supports, layer) {
if (typeof modules === "string") {
modules = [[null, modules, undefined]];
}
var alreadyImportedModules = {};
if (dedupe) {
for (var k = 0; k < this.length; k++) {
var id = this[k][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for (var _k = 0; _k < modules.length; _k++) {
var item = [].concat(modules[_k]);
if (dedupe && alreadyImportedModules[item[0]]) {
continue;
}
if (typeof layer !== "undefined") {
if (typeof item[5] === "undefined") {
item[5] = layer;
} else {
item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
item[5] = layer;
}
}
if (media) {
if (!item[2]) {
item[2] = media;
} else {
item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
item[2] = media;
}
}
if (supports) {
if (!item[4]) {
item[4] = "".concat(supports);
} else {
item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
item[4] = supports;
}
}
list.push(item);
}
};
return list;
};
/***/ }),
/***/ 885:
/***/ ((module) => {
module.exports = function (i) {
return i[1];
};
/***/ }),
/***/ 886:
/***/ ((module) => {
var stylesInDOM = [];
function getIndexByIdentifier(identifier) {
var result = -1;
for (var i = 0; i < stylesInDOM.length; i++) {
if (stylesInDOM[i].identifier === identifier) {
result = i;
break;
}
}
return result;
}
function modulesToDom(list, options) {
var idCountMap = {};
var identifiers = [];
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var count = idCountMap[id] || 0;
var identifier = "".concat(id, " ").concat(count);
idCountMap[id] = count + 1;
var indexByIdentifier = getIndexByIdentifier(identifier);
var obj = {
css: item[1],
media: item[2],
sourceMap: item[3],
supports: item[4],
layer: item[5]
};
if (indexByIdentifier !== -1) {
stylesInDOM[indexByIdentifier].references++;
stylesInDOM[indexByIdentifier].updater(obj);
} else {
var updater = addElementStyle(obj, options);
options.byIndex = i;
stylesInDOM.splice(i, 0, {
identifier: identifier,
updater: updater,
references: 1
});
}
identifiers.push(identifier);
}
return identifiers;
}
function addElementStyle(obj, options) {
var api = options.domAPI(options);
api.update(obj);
var updater = function updater(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
return;
}
api.update(obj = newObj);
} else {
api.remove();
}
};
return updater;
}
module.exports = function (list, options) {
options = options || {};
list = list || [];
var lastIdentifiers = modulesToDom(list, options);
return function update(newList) {
newList = newList || [];
for (var i = 0; i < lastIdentifiers.length; i++) {
var identifier = lastIdentifiers[i];
var index = getIndexByIdentifier(identifier);
stylesInDOM[index].references--;
}
var newLastIdentifiers = modulesToDom(newList, options);
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
var _identifier = lastIdentifiers[_i];
var _index = getIndexByIdentifier(_identifier);
if (stylesInDOM[_index].references === 0) {
stylesInDOM[_index].updater();
stylesInDOM.splice(_index, 1);
}
}
lastIdentifiers = newLastIdentifiers;
};
};
/***/ }),
/***/ 122:
/***/ ((module) => {
var memo = {};
/* istanbul ignore next */
function getTarget(target) {
if (typeof memo[target] === "undefined") {
var styleTarget = document.querySelector(target);
// Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
}
/* istanbul ignore next */
function insertBySelector(insert, style) {
var target = getTarget(insert);
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(style);
}
module.exports = insertBySelector;
/***/ }),
/***/ 611:
/***/ ((module) => {
/* istanbul ignore next */
function insertStyleElement(options) {
var element = document.createElement("style");
options.setAttributes(element, options.attributes);
options.insert(element, options.options);
return element;
}
module.exports = insertStyleElement;
/***/ }),
/***/ 791:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/* istanbul ignore next */
function setAttributesWithoutAttributes(styleElement) {
var nonce = true ? __webpack_require__.nc : 0;
if (nonce) {
styleElement.setAttribute("nonce", nonce);
}
}
module.exports = setAttributesWithoutAttributes;
/***/ }),
/***/ 788:
/***/ ((module) => {
/* istanbul ignore next */
function apply(styleElement, options, obj) {
var css = "";
if (obj.supports) {
css += "@supports (".concat(obj.supports, ") {");
}
if (obj.media) {
css += "@media ".concat(obj.media, " {");
}
var needLayer = typeof obj.layer !== "undefined";
if (needLayer) {
css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
}
css += obj.css;
if (needLayer) {
css += "}";
}
if (obj.media) {
css += "}";
}
if (obj.supports) {
css += "}";
}
var sourceMap = obj.sourceMap;
if (sourceMap && typeof btoa !== "undefined") {
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
}
// For old IE
/* istanbul ignore if */
options.styleTagTransform(css, styleElement, options.options);
}
function removeStyleElement(styleElement) {
// istanbul ignore if
if (styleElement.parentNode === null) {
return false;
}
styleElement.parentNode.removeChild(styleElement);
}
/* istanbul ignore next */
function domAPI(options) {
if (typeof document === "undefined") {
return {
update: function update() {},
remove: function remove() {}
};
}
var styleElement = options.insertStyleElement(options);
return {
update: function update(obj) {
apply(styleElement, options, obj);
},
remove: function remove() {
removeStyleElement(styleElement);
}
};
}
module.exports = domAPI;
/***/ }),
/***/ 671:
/***/ ((module) => {
/* istanbul ignore next */
function styleTagTransform(css, styleElement) {
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while (styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}
module.exports = styleTagTransform;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/nonce */
/******/ (() => {
/******/ __webpack_require__.nc = undefined;
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
// EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
var injectStylesIntoStyleTag = __webpack_require__(886);
var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
// EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/styleDomAPI.js
var styleDomAPI = __webpack_require__(788);
var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
// EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/insertBySelector.js
var insertBySelector = __webpack_require__(122);
var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
// EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
var setAttributesWithoutAttributes = __webpack_require__(791);
var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
// EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/insertStyleElement.js
var insertStyleElement = __webpack_require__(611);
var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
// EXTERNAL MODULE: ../../node_modules/.pnpm/style-loader@3.3.3_webpack@5.88.2/node_modules/style-loader/dist/runtime/styleTagTransform.js
var styleTagTransform = __webpack_require__(671);
var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
// 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
var styles = __webpack_require__(667);
;// CONCATENATED MODULE: ./src/styles/index.scss
var options = {};
options.styleTagTransform = (styleTagTransform_default());
options.setAttributes = (setAttributesWithoutAttributes_default());
options.insert = insertBySelector_default().bind(null, "head");
options.domAPI = (styleDomAPI_default());
options.insertStyleElement = (insertStyleElement_default());
var update = injectStylesIntoStyleTag_default()(styles/* default */.Z, options);
/* harmony default export */ const src_styles = (styles/* default */.Z && styles/* default */.Z.locals ? styles/* default */.Z.locals : undefined);
;// CONCATENATED MODULE: ./src/utils/index.js
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); }
var injection = function injection() {
!function (e) {
"use strict";
function t() {
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);
}
function n() {
return !!window.navigator.userAgent.toLowerCase().match(/(csdn)/i);
}
function o(e) {
for (var t = document.cookie.split("; "), n = 0; n < t.length; n++) {
var o = t[n].split("=");
if (e == o[0]) return o[1];
}
return null;
}
function i(e) {
var t = e.target || e.srcElement,
n = document.documentElement.scrollTop;
if (t.className.indexOf('hljs-button') > -1) {
e.preventDefault();
var o = document.getElementById("hljs-copy-el");
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");
try {
var i = document.execCommand("copy");
o.remove(), t.dataset.title = i ? b : y, i && setTimeout(function () {
t.dataset.title = x;
}, 3e3);
} catch (r) {
t.dataset.title = y;
}
}
}
function r(e) {
var t = e.target || e.srcElement,
n = document.documentElement.scrollTop;
if (t.className.indexOf("hljs-button") > -1) {
e.preventDefault();
var o = document.getElementById("hljs-copy-el");
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");
try {
var i = document.execCommand("copy");
o.remove(), t.dataset.title = i ? b : y, i && setTimeout(function () {
t.dataset.title = x;
}, 3e3);
} catch (r) {
t.dataset.title = y;
}
}
}
function a(e) {
if (e = "string" == typeof e ? document.querySelector(e) : e, navigator.userAgent.match(/ipad|ipod|iphone/i)) {
var t = e.contentEditable,
n = e.readOnly;
e.contentEditable = !0, e.readOnly = !0;
var o = document.createRange();
o.selectNodeContents(e);
var i = window.getSelection();
i.removeAllRanges(), i.addRange(o), e.setSelectionRange(0, 999999), e.contentEditable = t, e.readOnly = n;
} else e.select();
}
function c() {
var e = "z-index: 20;";
n() && (e = "z-index: 100002;");
var t = document.createElement("style");
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);
}
function d() {
"complete" === document.readyState ? l() : e.addEventListener("DOMContentLoaded", l);
}
function s(e) {
if (!$(this).hasClass("active")) {
if (!o("UserName")) return window.csdn.loginBox.show({
spm: "1001.2101.3001.10011"
}), void window.csdn.report.reportClick({
spm: "3001.10011"
});
window.csdn.report.reportClick({
spm: "3001.10012"
});
try {
var t = e.currentTarget.parentNode.innerText;
t = t.replaceAll("\n", "");
var n = $(".annotation-boxshadow").data("isblack"),
i = $(this).parents("pre").data("index") || "0",
r = !0;
$(".i-ai-code-bottom").hide(), codeMaxSize - t.length <= 0 && (r = !1), $(".annotation-content").attr("data-num", i), $("#annotation-iframe")[0].contentWindow.postMessage({
type: "blog-code-sin",
isblack: n,
content: t,
lengthFlag: r
}, "*"), $(".annotation-boxshadow").show(), $(".annotation-btn .annotation-def").show(), $(".annotation-btn .annotation-active").hide(), $(".annotation-btn").removeClass("active");
} catch (a) {
console.error("CopyButton error: ", a);
}
}
}
function p() {
try {
var e,
t = '<div class="code-annotation" data-title="一键注释"></div>';
if (overCost || !canRead) return;
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) {
n && (n.innerHTML = n.innerHTML + t);
})) : (e = $("pre code"), e.each(function (e, n) {
n && (n.innerHTML = n.innerHTML + t);
})), $(document).on("click", "pre .code-annotation", s);
var n = "3001.10012";
o("UserName") || (n = "3001.10011"), window.csdn.report && "function" == typeof window.csdn.report.reportView && window.csdn.report.reportView({
spm: n
});
} catch (i) {
console.error("CopyButton error: ", i);
}
}
function l() {
try {
var e;
if ("ckeditor" == C) {
e = document.querySelectorAll("code.hljs");
for (var i in e) e.hasOwnProperty(i) && u(e[i].parentNode);
} else {
e = A;
for (var i in e) e.hasOwnProperty(i) && u(e[i]);
}
t() || n() || ($("#annotation-iframe").length > 0 && o("UserName") ? $("#annotation-iframe").on("load", function () {
p();
}) : p());
} catch (r) {
console.error("CopyButton error: ", r);
}
}
function m(e) {
var i = e.target || e.srcElement;
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({
spm: "1001.2101.3001.7759"
}) : o("UserName") || window.csdn.loginBox.show({
spm: "1001.2101.3001.4334"
}));
}
function u(e) {
var t = "";
if ("object" == _typeof(e) && null !== e) {
var n = ".signin(event)",
o = "hljs",
i = ".copyCode(event)";
"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");
}
}
function f(e) {
var t = "1001.2101.3001.4259",
n = JSON.stringify({
codeId: e
});
if (window.csdn.report && "function" == typeof window.csdn.report.reportClick) window.csdn.report.reportClick({
spm: t,
extra: n
});else if (window.isApp) {
var o = {
spm: t,
extra: n
},
i = {
trackingInfo: JSON.stringify(o)
};
g && window.jsCallBackListener.csdntrackclick(JSON.stringify(i)), h && window.webkit.messageHandlers.csdntrackclick.postMessage(JSON.stringify(i));
}
}
window.copyCode = r;
if (window.ActiveXObject || "ActiveXObject" in window) return !1;
var w = navigator.userAgent,
g = w.indexOf("Android") > -1 || w.indexOf("Adr") > -1,
h = !!w.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
v = "hljs-button",
x = "复制",
y = "复制失败",
b = "已复制",
C = void 0,
k = "",
j = !1;
n() || o("UserName") || (j = !0), j && (x = "登录复制", k = "signin"), $("#content_views").find("pre").each(function (e, t) {
$(t).attr("data-index", e);
}), String.prototype.format = String.prototype.f = function () {
var e = arguments;
return !!this && this.replace(/\{(\d+)\}/g, function (t, n) {
return e[n] ? e[n] : t;
});
};
var A = document.querySelectorAll("pre code");
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) {
if (!n()) {
var o = t() ? "3001.10057" : "3001.10056";
window.csdn.report.reportClick({
spm: o
});
}
});
}(window);
};
;// CONCATENATED MODULE: ./src/components/ui.js
var dq = document.querySelector.bind(document);
var timer = null;
var copyCodeGreen = function copyCodeGreen(event) {
console.log('copy do');
$(".hljs-button").removeClass("success");
try {
window.copyCode(event);
console.log('copy success');
$(event.target).addClass("success");
} catch (error) {
console.log('copy failure', error);
}
clearTimeout(timer);
timer = setTimeout(function () {
$(".hljs-button").removeClass("success");
}, 3000);
};
function UI() {
this.init();
}
UI.prototype.init = function () {
console.log("[info] 欢迎使用 [CSDN 绿化] 插件");
};
UI.prototype.mounted = function () {
this.body = document.body;
};
UI.prototype.csdn = function () {
this.body.classList.add("csdn");
this.mode = "home";
this.blog_content = dq("#article_content");
if (this.blog_content) {
this.blog_content.classList.add("markdown-body");
this.mode = "article";
} else if (window.location.href.includes("category")) {
this.mode = "category";
} else {
this.mode = "menu";
}
this.body.classList.add(this.mode);
this.ads = [".csdn-side-toolbar", "#asideHotArticle", "#asideArchive", ".passport-login-mark"];
this.process();
};
UI.prototype.process = function () {
this.processRemoveAD();
this.processClipboard();
};
UI.prototype.processRemoveAD = function () {
if (this.ads && this.ads.length) {
this.ads.forEach(function (selector) {
var ad = dq(selector);
console.log("[info] 去除广告", selector);
if (ad) ad.parentElement.removeChild(ad);
});
}
};
UI.prototype.processClipboard = function () {
injection();
// 去除剪贴板劫持
try {
Object.defineProperty(window, "articleType", {
value: 0,
writable: false,
configurable: false
});
$("#csdn-toolbar").css("border-bottom", "2px solid #4abf8a");
} catch (err) {
$("#csdn-toolbar").css("border-bottom", "2px solid #f56c6c");
}
// 修复无法复制
$("pre").css("user-select", "auto");
$("code").css("user-select", "auto");
$("blockquote").css("user-select", "auto");
// 拦截登录
$(".hljs-button").removeClass("signin");
$(".hljs-button").removeAttr("data-report-click");
$(".hljs").removeAttr("onclick");
$(".hljs-button").removeAttr("onclick");
$(".hljs-button").css("font-size", "12px");
// 点击复制
var buttons = document.getElementsByClassName("hljs-button");
Array.from(buttons).forEach(function (button) {
button.onclick = copyCodeGreen;
});
var alwaysDo = function alwaysDo() {
if (window.csdn && csdn.copyright) {
csdn.copyright.textData = "";
csdn.copyright.htmlData = "";
}
$(".hljs-button").attr("data-title", "免登录复制");
$(".hljs-button").css("background-color", "#409eff");
$(".hljs-button.success").attr("data-title", "复制成功!");
$(".hljs-button.success").css("background-color", "#4abf8a");
window.requestAnimationFrame(alwaysDo);
};
window.requestAnimationFrame(alwaysDo);
};
/* harmony default export */ const ui = (UI);
;// CONCATENATED MODULE: ./src/main.js
var isInit = false;
var main_ui = new ui();
(function () {
window.addEventListener("load", function () {
init();
});
})();
function init() {
if (isInit) return;
isInit = true;
main_ui.mounted();
main_ui.csdn();
document.body.style.display = "block";
console.log("[info] Finshed");
}
})();
/******/ })()
;