vite-monkey-csdn-test

CSDN 删除广告 DEMO

  1. // ==UserScript==
  2. // @name vite-monkey-csdn-test
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @author wyd
  6. // @description CSDN 删除广告 DEMO
  7. // @include *://*.csdn.net/*
  8. // @require https://cdn.jsdelivr.net/npm/vue@3.4.27/dist/vue.global.prod.js
  9. // @require data:application/javascript,window.Vue%3DVue%3B
  10. // @require https://cdn.jsdelivr.net/npm/element-plus@2.7.3/dist/index.full.min.js
  11. // @resource element-plus/dist/index.css https://cdn.jsdelivr.net/npm/element-plus@2.7.3/dist/index.css
  12. // @grant GM_addStyle
  13. // @grant GM_getResourceText
  14. // ==/UserScript==
  15.  
  16. (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const e=document.createElement("style");e.textContent=t,document.head.append(e)})(" .v-button[data-v-ba5aff76]{width:44px!important;height:44px!important;font-size:32px!important;margin-top:8px} ");
  17.  
  18. (function (vue, elementPlus) {
  19. 'use strict';
  20.  
  21. /*! Element Plus Icons Vue v2.3.1 */
  22. var star_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
  23. name: "Star",
  24. __name: "star",
  25. setup(__props) {
  26. return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", {
  27. xmlns: "http://www.w3.org/2000/svg",
  28. viewBox: "0 0 1024 1024"
  29. }, [
  30. vue.createElementVNode("path", {
  31. fill: "currentColor",
  32. d: "m512 747.84 228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72zM313.6 924.48a70.4 70.4 0 0 1-102.144-74.24l37.888-220.928L88.96 472.96A70.4 70.4 0 0 1 128 352.896l221.76-32.256 99.2-200.96a70.4 70.4 0 0 1 126.208 0l99.2 200.96 221.824 32.256a70.4 70.4 0 0 1 39.04 120.064L774.72 629.376l37.888 220.928a70.4 70.4 0 0 1-102.144 74.24L512 820.096l-198.4 104.32z"
  33. })
  34. ]));
  35. }
  36. });
  37. var star_default = star_vue_vue_type_script_setup_true_lang_default;
  38. const _withScopeId = (n) => (vue.pushScopeId("data-v-ba5aff76"), n = n(), vue.popScopeId(), n);
  39. const _hoisted_1 = { class: "app" };
  40. const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("span", null, "This is a message", -1));
  41. const _hoisted_3 = { class: "dialog-footer" };
  42. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  43. __name: "App",
  44. setup(__props) {
  45. const dialogVisible = vue.ref(false);
  46. const handleClose = (done) => {
  47. elementPlus.ElMessageBox.confirm("Are you sure to close this dialog?").then(() => {
  48. done();
  49. }).catch(() => {
  50. });
  51. };
  52. const handleOpen = () => {
  53. dialogVisible.value = true;
  54. };
  55. return (_ctx, _cache) => {
  56. return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
  57. vue.createElementVNode("div", _hoisted_1, [
  58. vue.createVNode(vue.unref(elementPlus.ElButton), {
  59. color: "white",
  60. type: "warning",
  61. icon: vue.unref(star_default),
  62. size: "large",
  63. circle: "",
  64. class: "v-button",
  65. onClick: handleOpen
  66. }, null, 8, ["icon"])
  67. ]),
  68. vue.createVNode(vue.unref(elementPlus.ElDialog), {
  69. modelValue: dialogVisible.value,
  70. "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => dialogVisible.value = $event),
  71. title: "Tips",
  72. width: "500",
  73. "before-close": handleClose
  74. }, {
  75. footer: vue.withCtx(() => [
  76. vue.createElementVNode("div", _hoisted_3, [
  77. vue.createVNode(vue.unref(elementPlus.ElButton), {
  78. onClick: _cache[0] || (_cache[0] = ($event) => dialogVisible.value = false)
  79. }, {
  80. default: vue.withCtx(() => [
  81. vue.createTextVNode("Cancel")
  82. ]),
  83. _: 1
  84. }),
  85. vue.createVNode(vue.unref(elementPlus.ElButton), {
  86. type: "primary",
  87. onClick: _cache[1] || (_cache[1] = ($event) => dialogVisible.value = false)
  88. }, {
  89. default: vue.withCtx(() => [
  90. vue.createTextVNode(" Confirm ")
  91. ]),
  92. _: 1
  93. })
  94. ])
  95. ]),
  96. default: vue.withCtx(() => [
  97. _hoisted_2
  98. ]),
  99. _: 1
  100. }, 8, ["modelValue"])
  101. ], 64);
  102. };
  103. }
  104. });
  105. const _export_sfc = (sfc, props) => {
  106. const target = sfc.__vccOpts || sfc;
  107. for (const [key, val] of props) {
  108. target[key] = val;
  109. }
  110. return target;
  111. };
  112. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ba5aff76"]]);
  113. var _GM_addStyle = /* @__PURE__ */ (() => typeof GM_addStyle != "undefined" ? GM_addStyle : void 0)();
  114. const cssLoader = (e) => {
  115. const t = GM_getResourceText(e);
  116. return GM_addStyle(t), t;
  117. };
  118. cssLoader("element-plus/dist/index.css");
  119. function init() {
  120. console.log("vite-monkey-csdn-script init");
  121. _GM_addStyle(".login-mark,#passportbox{display:none!important;}");
  122. _GM_addStyle(".passport-login-container{display:none!important;}");
  123. $("li[data-type='ad']").remove();
  124. $("div[id^=kp_box]").remove();
  125. $(".recommend-box").remove();
  126. $(".blog-footer-bottom").remove();
  127. $("#asideWriteGuide").remove();
  128. $("div[data-pid='blog']").remove();
  129. $("#csdn-redpack").remove();
  130. $(".toolbar-advert").remove();
  131. $(".hljs-button").removeClass("signin");
  132. $(".hljs-button").addClass("{2}");
  133. $(".hljs-button").attr("data-title", "免登录复制");
  134. $(".hljs-button").attr("onclick", "hljs.copyCode(event)");
  135. $("code").attr("onclick", "mdcp.copyCode(event)");
  136. try {
  137. Object.defineProperty(window, "articleType", {
  138. value: 0,
  139. writable: false,
  140. configurable: false
  141. });
  142. } catch (err) {
  143. }
  144. var ef = document.getElementsByClassName("hide-article-box text-center")[0];
  145. if (ef) {
  146. ef.remove();
  147. document.getElementById("article_content").style.height = "auto";
  148. }
  149. }
  150. vue.createApp(App).mount(
  151. (() => {
  152. var _a;
  153. const app = document.createElement("div");
  154. (_a = $(".option-box[data-type='cs']")) == null ? void 0 : _a.after(app);
  155. init();
  156. return app;
  157. })()
  158. );
  159.  
  160. })(Vue, ElementPlus);