Bing: Strict Mode Always Off

Set Bing strict mode to off, always.

  1. // ==UserScript==
  2. // @name Bing: Strict Mode Always Off
  3. // @namespace Violentmonkey Scripts
  4. // @match *://*.bing.com/*
  5. // @grant none
  6. // @version 1.1
  7. // @author Chaewon
  8. // @license Unlicense
  9. // @icon https://www.bing.com/favicon.ico
  10. // @description Set Bing strict mode to off, always.
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15. /**
  16. * Retrieve the value of a specific cookie by name.
  17. * @param {string} name - The name of the cookie.
  18. * @returns {string|null} The value of the cookie or null if not found.
  19. */
  20. function getCookie(name) {
  21. const nameEQ = name + "=";
  22. const cookies = document.cookie.split(";");
  23. for (let i = 0; i < cookies.length; i++) {
  24. let cookie = cookies[i].trim();
  25. if (cookie.indexOf(nameEQ) === 0) {
  26. return cookie.substring(nameEQ.length, cookie.length);
  27. }
  28. }
  29. return null;
  30. }
  31.  
  32. /**
  33. * Set a cookie with a specific name, value, and expiry.
  34. * @param {string} name - The name of the cookie.
  35. * @param {string} value - The value of the cookie.
  36. * @param {number} days - The number of days until the cookie expires.
  37. */
  38. function setCookie(name, value, days) {
  39. const expires = days
  40. ? "; expires=" + new Date(Date.now() + days * 864e5).toUTCString()
  41. : "";
  42. document.cookie = name + "=" + value + expires + "; path=/; Secure";
  43. }
  44.  
  45. let bingCookie = getCookie("SRCHHPGUSR");
  46. if (bingCookie) {
  47. let params = new URLSearchParams(bingCookie.replace(/;/g, "&"));
  48. if (params.has("ADLT")) {
  49. const adltValue = params.get("ADLT");
  50. if (adltValue === "OFF") {
  51. console.log("Cookie already set to ADLT=OFF");
  52. return;
  53. } else {
  54. params.set("ADLT", "OFF");
  55. let updatedCookie = params.toString();
  56. console.log("Updated cookie: " + updatedCookie);
  57. setCookie("SRCHHPGUSR", updatedCookie, 365);
  58. location.reload();
  59. }
  60. } else {
  61. params.set("ADLT", "OFF");
  62. let updatedCookie = params.toString();
  63. console.log("Updated cookie: " + updatedCookie);
  64. setCookie("SRCHHPGUSR", updatedCookie, 365);
  65. location.reload();
  66. }
  67. } else {
  68. console.log("Cookie not found.");
  69. }
  70. })();