Remove Bing Character Limit

Removes character limit from search input field

  1. // ==UserScript==
  2. // @name Remove Bing Character Limit
  3. // @version 2.2
  4. // @description Removes character limit from search input field
  5. // @match https://www.bing.com/*
  6. // @run-at document-end
  7. // @license MIT
  8. // @namespace NOLIMIT
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. "use strict";
  13.  
  14. async function waitForElement(root, selector) {
  15. return new Promise((resolve, reject) => {
  16. if (root.querySelector(selector)) {
  17. resolve(root.querySelector(selector));
  18. } else {
  19. const observer = new MutationObserver((mutations) => {
  20. mutations.forEach((mutation) => {
  21. if (mutation.type === "childList") {
  22. if (root.querySelector(selector)) {
  23. resolve(root.querySelector(selector));
  24. observer.disconnect();
  25. clearTimeout(timeout);
  26. }
  27. }
  28. });
  29. });
  30. observer.observe(root, { childList: true, subtree: true });
  31. const timeout = setTimeout(() => {
  32. observer.disconnect();
  33. reject(new Error("Timeout"));
  34. }, 10000);
  35. }
  36. });
  37. }
  38.  
  39. async function removeCharLimit() {
  40. const serp = await waitForElement(
  41. document,
  42. "cib-serp[serp-slot='none']"
  43. );
  44. const serpShadowRoot = serp.shadowRoot;
  45. const actionBar = await waitForElement(
  46. serpShadowRoot,
  47. "cib-action-bar"
  48. );
  49. const actionBarShadowRoot = actionBar.shadowRoot;
  50. const serpTextInput = await waitForElement(
  51. actionBarShadowRoot,
  52. "cib-text-input[serp-slot='none']"
  53. );
  54. const serpTextInputShadowRoot = serpTextInput.shadowRoot;
  55. const textarea = await waitForElement(
  56. serpTextInputShadowRoot,
  57. "textarea[maxlength]"
  58. );
  59. textarea.removeAttribute("maxlength");
  60. const letterCounter = await waitForElement(
  61. actionBarShadowRoot,
  62. ".letter-counter"
  63. );
  64. letterCounter.childNodes[
  65. letterCounter.childNodes.length - 1
  66. ].textContent = "∞";
  67.  
  68. // Add mutation observer to textarea
  69. const config = { attributes: true, childList: false, subtree: false };
  70. const callback = function (mutationsList, observer) {
  71. for (const mutation of mutationsList) {
  72. if (mutation.type === 'attributes') {
  73. textarea.removeAttribute("maxlength");
  74. console.log('Attribute ' + mutation.attributeName + ' changed to: ' + textarea.getAttribute(mutation.attributeName));
  75. }
  76. }
  77. };
  78. const observer = new MutationObserver(callback);
  79. observer.observe(textarea, config);
  80. }
  81.  
  82. window.addEventListener("load", removeCharLimit);
  83. window.addEventListener("popstate", removeCharLimit);
  84. })();