Greasy Fork

Greasy Fork is available in English.

批量删除新浪微博博文

批量删除新浪微博

目前为 2022-08-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         批量删除新浪微博博文
// @namespace    https://github.com/dxhuii/delWeibo
// @version      1.1.0
// @author       plain
// @description  批量删除新浪微博
// @license      MIT
// @icon         https://weibo.com/favicon.ico
// @match        *://weibo.com/*/profile?*
// @match        *://weibo.com/u/*
// @match        *://weibo.com/fav*
// @match        *://weibo.com/u/page/fav/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.js
// ==/UserScript==

// use [email protected] at 2022-08-04T17:38:14.435Z

;(({ cssText = "" }) => {
  const style = document.createElement("style");
  style.innerText = cssText;
  style.dataset.source = "vite-plugin-monkey";
  document.head.appendChild(style);
})({
  "cssText": "\n.del-weibo[data-v-81a5ea4f] {\n  position: fixed;\n  right: 0;\n  top: 50%;\n  transform: translateY(-50%);\n  z-index: 9999999;\n}\n"
});

(function(vue) {
  "use strict";
  const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
    __name: "DelWeibo",
    setup(__props) {
      const start = vue.ref(0);
      function $(elem) {
        return document.querySelector(elem);
      }
      function $All(elem) {
        return document.querySelectorAll(elem);
      }
      function $$(elem, el) {
        return $(elem).querySelectorAll(el)[1];
      }
      function del() {
        const url = window.location.href;
        for (let i = 0; i < 1e3; i++) {
          setTimeout(function() {
            if (url.indexOf("//weibo.com/u/page/fav/") !== -1) {
              if ($('i[title="\u66F4\u591A"]')) {
                $('i[title="\u66F4\u591A"]').click();
                $All(".woo-pop-item-main")[0].click();
                if ($(".woo-dialog-ctrl")) {
                  $$(".woo-dialog-ctrl", ".woo-button-main").click();
                }
                i > 5 && window.location.reload();
              }
            }
            if (url.indexOf("/profile") !== -1) {
              if ($('a[action-type="fl_menu"]')) {
                $('a[action-type="fl_menu"]').click();
                $('a[title="\u5220\u9664\u6B64\u6761\u5FAE\u535A"]').click();
                $('a[action-type="ok"]').click();
                $('a[title="\u53D6\u6D88\u5FEB\u8F6C"]').click();
              }
            }
            if (url.indexOf("//weibo.com/fav") !== -1) {
              if ($('a[action-type="fl_favorite"]')) {
                $('a[action-type="fl_favorite"]').click();
                $('a[action-type="ok"]').click();
              }
            }
            if (url.indexOf("//weibo.com/u/") !== -1) {
              if ($('i[title="\u66F4\u591A"]') || $('i[title="\u8D1F\u53CD\u9988"]')) {
                if ($('i[title="\u66F4\u591A"]')) {
                  $('i[title="\u66F4\u591A"]').click();
                }
                if ($('i[title="\u8D1F\u53CD\u9988"]')) {
                  $('i[title="\u8D1F\u53CD\u9988"]').click();
                }
                const item = $All(".woo-pop-item-main");
                if (item.length > 3) {
                  item[item.length - 3].click();
                } else {
                  if (item.length > 1) {
                    item[1].click();
                  } else {
                    $(".woo-pop-item-main") && $(".woo-pop-item-main").click();
                  }
                }
                $(".woo-dialog-ctrl") && $$(".woo-dialog-ctrl", ".woo-button-main").click();
                if ($(".deletedToolbar_toolbarFull_1dOfW")) {
                  $(".deletedToolbar_toolbarFull_1dOfW").click();
                }
                i > 160 && window.location.reload();
              }
            }
          }, 1e3 * i);
        }
      }
      const onStart = () => {
        console.log("\u5F00\u59CB");
        localStorage.delWeibo = "start";
        start.value = 1;
        del();
      };
      const onEnd = () => {
        console.log("\u7ED3\u675F");
        localStorage.delWeibo = "end";
        start.value = 0;
        window.location.reload();
      };
      vue.watchEffect(() => {
        if (localStorage.delWeibo === "start") {
          del();
          start.value = 1;
        }
      });
      return (_ctx, _cache) => {
        return start.value ? (vue.openBlock(), vue.createElementBlock("button", {
          key: 0,
          class: "del-weibo",
          onClick: onEnd
        }, "\u7ED3\u675F")) : (vue.openBlock(), vue.createElementBlock("button", {
          key: 1,
          class: "del-weibo",
          onClick: onStart
        }, "\u5F00\u59CB"));
      };
    }
  });
  const DelWeibo_vue_vue_type_style_index_0_scoped_81a5ea4f_lang = "";
  const _export_sfc = (sfc, props) => {
    const target = sfc.__vccOpts || sfc;
    for (const [key, val] of props) {
      target[key] = val;
    }
    return target;
  };
  const DelWeibo = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-81a5ea4f"]]);
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
    __name: "App",
    setup(__props) {
      return (_ctx, _cache) => {
        return vue.openBlock(), vue.createBlock(DelWeibo);
      };
    }
  });
  vue.createApp(_sfc_main).mount(
    (() => {
      const app = document.createElement("div");
      document.body.append(app);
      return app;
    })()
  );
})(Vue);