Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化了删除效率: 含修改源码 #6

Closed
hhstore opened this issue Dec 10, 2021 · 1 comment
Closed

优化了删除效率: 含修改源码 #6

hhstore opened this issue Dec 10, 2021 · 1 comment

Comments

@hhstore
Copy link

hhstore commented Dec 10, 2021

更改说明:

  • 只是更改了 for( i<1000;)
  • 以及延迟了 reload() 的页面判断为 i > 160
  • 当前版本的微博首页, 会自动懒加载. 其实 reload 的延迟可以设置很久.

repo 插件的缺陷:

  • 删2条微博, 就会刷新页面 reload, 执行效率太低了.
  • 比手动删, 快不了多少.

优化版本:

  • 油猴插件, 可以直接改js 脚本, 保存后. 刷新 微博主页, 就能生效.
  • 懒得给作者提 PR 了.

使用方式: 油猴插件+编辑脚本文件(替换我如下源码)

  • 看到的朋友. 可以用我下面这个脚本. 其他逻辑都没有改动.
  • 再次感谢作者. 好人.
// ==UserScript==
// @name         批量删除新浪微博博文
// @namespace    https://github.com/dxhuii/delWeibo
// @version      1.0.10
// @description  批量删除新浪微博
// @author       plain
// @match        *://weibo.com/*/profile?*
// @match        *://weibo.com/u/*
// @match        *://weibo.com/fav*
// @match        *://weibo.com/u/page/fav/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.onload = () => {
        function $(elem) {
            return document.querySelector(elem);
        }
        function $All(elem) {
            return document.querySelectorAll(elem);
        }
        function del() {
            for (let i = 0; i < 1000; i++) {
                setTimeout(function() {
                    if(window.location.href.indexOf('//weibo.com/u/page/fav/') !== -1) { // 新
                        if($('i[title="更多"]')) {
                            $('i[title="更多"]').click();
                            $All('.woo-pop-item-main')[0].click();
                            if($('.woo-dialog-ctrl')) {
                                $('.woo-dialog-ctrl').querySelectorAll('.woo-button-main')[1].click();
                            }
                            i > 160 && window.location.reload();
                        }
                    }

                    if(window.location.href.indexOf('/profile') !== -1) { // 旧
                        if($('a[action-type="fl_menu"]')) {
                            $('a[action-type="fl_menu"]').click();
                            $('a[title="删除此条微博"]').click();
                            $('a[action-type="ok"]').click();
                            $('a[title="取消快转"]').click();
                        }
                    }
                    if(window.location.href.indexOf('//weibo.com/fav') !== -1) { // 旧,github网友提供 https://github.com/Syukkic
                        if($('a[action-type="fl_favorite"]')) {
                            $('a[action-type="fl_favorite"]').click();
                            $('a[action-type="ok"]').click();
                        }
                    }

                    if(window.location.href.indexOf('//weibo.com/u/') !== -1) { // 新
                        if($('i[title="更多"]')) {
                            $('i[title="更多"]').click();
                            const item = $All('.woo-pop-item-main');
                            if(item.length > 3) {
                                item[item.length - 2].click();
                            } else {
                                $('.woo-pop-item-main') && $('.woo-pop-item-main').click();
                            }
                            $('.woo-dialog-ctrl') && $('.woo-dialog-ctrl').querySelectorAll('.woo-button-main')[1].click();
                            if($('.deletedToolbar_toolbarFull_1dOfW')) {
                                $('.deletedToolbar_toolbarFull_1dOfW').click();
                            }
                            i > 160 && window.location.reload();
                        }
                    }
                }, 1000 * i);
            }
        }

        // 判断如果有cookie 就不再弹窗,直接进行删除微薄
        if(document.cookie.indexOf('delWeibo=1') !== -1) {
            del();
        } else {
            var r = confirm("确定好要删除所有微薄了吗,确定好了就点确定吧!");
            if (r === true) {
                document.cookie = 'delWeibo=1';
                del();
            }
        }
    };
})();
@hhstore hhstore changed the title 优化了删除效率 优化了删除效率: 含修改源码 Dec 10, 2021
@dxhuii
Copy link
Owner

dxhuii commented Aug 25, 2022

已更新

@dxhuii dxhuii closed this as completed Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants