LinkedIn Comments Deleter

Deletes ALL of your comments on Linkedin

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         LinkedIn Comments Deleter
// @namespace    greaseyfork_linkedin_com_del
// @version      2024-12-16.0
// @description  Deletes ALL of your comments on Linkedin
// @author       Henrique Bucher ([email protected])
// @include      https://www.linkedin.com/in/*/recent-activity/comments/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linkedin.com
// @grant        GM_log
// @license      MIT
// ==/UserScript==

// WARNING:
// THIS WILL IMMEDIATELY START DELETING ***ALL*** OF YOUR COMMENTS ON LINKEDIN
// THE SCRIPT WILL RUN AS SOON AS YOU VISIT THE FOLLOWING PAGE:
// https://www.linkedin.com/your_activity/recent-activity/comments
// BE ABSOLUTELY SURE YOU WANT THIS!!!

(function() {
    'use strict';

    let MIN_CLICK_MS = 3000
    let MAX_CLICK_MS = 6000
    let MIN_RELOAD_MS = 5000
    let MAX_RELOAD_MS = 10000

    function sleep(mintime,maxtime) {
      let ms = Math.floor(Math.random()*(maxtime-mintime) + mintime);
      return new Promise(resolve => setTimeout(resolve, ms));
    }

    function remove_all() {
        let button_list = document.querySelectorAll('div.comment-options-trigger > div.artdeco-dropdown > button.artdeco-dropdown__trigger');

        for (let i = 0;i < button_list.length;i++){
            let button = button_list[i];
            button.click();
            sleep(MIN_CLICK_MS, MAX_CLICK_MS);

            // Click on the "Delete" option (2nd)
            let options = document.getElementsByClassName("comment-options-dropdown__option-text");
            options[2].click();
            sleep(MIN_CLICK_MS, MAX_CLICK_MS);

            // Confirm the modal dialog
            let modal_options = document.querySelectorAll("div.artdeco-modal__actionbar > button.artdeco-button > span.artdeco-button__text");
            modal_options[1].click();
            sleep(MIN_CLICK_MS, MAX_CLICK_MS);
        }
        sleep(MIN_RELOAD_MS, MAX_RELOAD_MS);
    }

    GM_log("-------------------- Linkedin Comment Delete Started" )

    remove_all();
    sleep(MIN_RELOAD_MS, MAX_RELOAD_MS);
    location.reload();

})();