您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Set Bing strict mode to off, always.
- // ==UserScript==
- // @name Bing: Strict Mode Always Off
- // @namespace Violentmonkey Scripts
- // @match *://*.bing.com/*
- // @grant none
- // @version 1.1
- // @author Chaewon
- // @license Unlicense
- // @icon https://www.bing.com/favicon.ico
- // @description Set Bing strict mode to off, always.
- // ==/UserScript==
- (function () {
- "use strict";
- /**
- * Retrieve the value of a specific cookie by name.
- * @param {string} name - The name of the cookie.
- * @returns {string|null} The value of the cookie or null if not found.
- */
- function getCookie(name) {
- const nameEQ = name + "=";
- const cookies = document.cookie.split(";");
- for (let i = 0; i < cookies.length; i++) {
- let cookie = cookies[i].trim();
- if (cookie.indexOf(nameEQ) === 0) {
- return cookie.substring(nameEQ.length, cookie.length);
- }
- }
- return null;
- }
- /**
- * Set a cookie with a specific name, value, and expiry.
- * @param {string} name - The name of the cookie.
- * @param {string} value - The value of the cookie.
- * @param {number} days - The number of days until the cookie expires.
- */
- function setCookie(name, value, days) {
- const expires = days
- ? "; expires=" + new Date(Date.now() + days * 864e5).toUTCString()
- : "";
- document.cookie = name + "=" + value + expires + "; path=/; Secure";
- }
- let bingCookie = getCookie("SRCHHPGUSR");
- if (bingCookie) {
- let params = new URLSearchParams(bingCookie.replace(/;/g, "&"));
- if (params.has("ADLT")) {
- const adltValue = params.get("ADLT");
- if (adltValue === "OFF") {
- console.log("Cookie already set to ADLT=OFF");
- return;
- } else {
- params.set("ADLT", "OFF");
- let updatedCookie = params.toString();
- console.log("Updated cookie: " + updatedCookie);
- setCookie("SRCHHPGUSR", updatedCookie, 365);
- location.reload();
- }
- } else {
- params.set("ADLT", "OFF");
- let updatedCookie = params.toString();
- console.log("Updated cookie: " + updatedCookie);
- setCookie("SRCHHPGUSR", updatedCookie, 365);
- location.reload();
- }
- } else {
- console.log("Cookie not found.");
- }
- })();