DuckDuckGo layout cleaner

Remove useless clutter from duckduckgo.com

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DuckDuckGo layout cleaner
// @namespace    duckduckgo_layout_cleaner
// @description  Remove useless clutter from duckduckgo.com
// @match        *://duckduckgo.com/*
// @match        *://duckduckgo.com/*
// @run-at       document-end
// @encoding     utf-8
// @license      MIT
// @version      2025.05.30
// ==/UserScript==

function removeByClass(clsname) {
    var a1 = document.getElementsByClassName(clsname);
    for(var i=0;i<a1.length;i++) a1[i].parentNode.removeChild(a1[i]);
}

(function() {
    setTimeout(function() {
        removeByClass('js-tagline');
        removeByClass("header--aside__item");
        removeByClass("header--aside__item social");
        removeByClass("feedback-prompt");
        removeByClass("js-feedback-btn-wrap");
        removeByClass("footer");
        removeByClass("badge-link");
        removeByClass("js-onboarding-ed");
        removeByClass("content-info__items");
        removeByClass("content-info__title");
        removeByClass("E4_TKgKL7YzziY_dW6E9"); // remove "Can’t find what you’re looking for?"
        removeByClass("text_promo--text");
        removeByClass("related-searches");
    }, 1000);
})();

// aiChatPromptSuggestions: {"hideSuggestions":true}
localStorage.setItem('aiChatPromptSuggestions', '{"hideSuggestions":true}')

// aichatPromoDismissal: {"promosDismissed":"2025-04-06"}
var date = new Date()
var dt = `${date.getYear()+1900}-${(date.getMonth()+1).toString().padStart(2,"0")}-${date.getDay().toString().padStart(2, "0")}`
localStorage.setItem('aichatPromoDismissal', '{"promosDismissed":"'+dt+'"}')


// localstorege duckduckgo_settings tests:
// chat on:  {}
// chat off: {"kbg":"-1"}
// ai assist often: {"kbe":"3"}
// ai assist never: {"kbe":"0"}

var ddg_settings = JSON.parse(localStorage.getItem('duckduckgo_settings')) || {};

ddg_settings['kbg'] = '-1'; // ai chat off
ddg_settings['kbe'] = '0'; // ai assist never

// turn off futher annoyances
ddg_settings['kpsb'] = '-1'; // dismiss "always private" self advertising
ddg_settings["kau"] = "-1"; // OFF: "It's okay to (very infrequently) ask me about my experience using DuckDuckGo"
ddg_settings["kao"] = "-1"; // OFF: "Shows the privacy benefits of using DuckDuckGo on the homepage"
ddg_settings["kap"] = "-1"; // OFF: "Shows occasional reminders to sign up for the DuckDuckGo privacy newsletters"
ddg_settings["kaq"] = "-1"; // OFF: "Shows sign-up form for the DuckDuckGo privacy newsletters"
ddg_settings["kax"] = "-1"; // OFF: "Shows occasional reminders to add DuckDuckGo to your browser"
ddg_settings["kak"] = "-1"; // OFF: "Shows links to instructions for how to add DuckDuckGo to your browser"

localStorage.setItem('duckduckgo_settings', JSON.stringify(ddg_settings));