Bing disable safesearch

Set off bing safesearch

目前为 2023-07-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         Bing disable safesearch
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Set off bing safesearch
// @author       You
// @match        https://www.bing.com/search?*
// @match        https://www.bing.com/images/search?*
// @match        https://www.bing.com/videos/search?*
// @match        https://www.bing.com/news/search?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    var oldCookieGetAccess = false;
    if(typeof window.cookieGetAccess != "undefined") {
       oldCookieGetAccess = window.cookieGetAccess;
    }
    //bing overwrites document.cookie function to return "" if this variable is false
    window.cookieGetAccess = true;
    var cookies = document.cookie;
    window.cookieGetAccess = oldCookieGetAccess;
    /*if(cookies == ""){
        cookies = cookieDesc.get.call(document);
    }*/
    var SRCHHPGUSR = cookies.match(/SRCHHPGUSR[^;]*/)[0];
    if(SRCHHPGUSR.includes("ADLT=") == true){
        if(SRCHHPGUSR.includes("ADLT=OFF") == false){
            SRCHHPGUSR = SRCHHPGUSR.replace(/ADLT=[^&]*/,"ADLT=OFF");
            cookieInjection();
        } else {
            if(performance.getEntriesByType("navigation")[0] && performance.getEntriesByType("navigation")[0].type!="reload"){
                console.log("Bing disable safesearch: nothing to do!");
            }
        }
    } else {
        SRCHHPGUSR = SRCHHPGUSR + "&ADLT=OFF";
        cookieInjection();
    }

    function cookieInjection() {
        document.cookie = SRCHHPGUSR+"; expires=Fri, 01 Jan 2038 00:00:00 GMT; domain=.bing.com; path =/; Secure";
        location.reload();
        console.log("Bing disable safesearch: done!");
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址