DuckDuckGo: Shorten Page Title

Simply sets and updates page title to search terms.

  1. // ==UserScript==
  2. // @name DuckDuckGo: Shorten Page Title
  3. // @namespace Violentmonkey Scripts
  4. // @match https://*.duckduckgo.com/*
  5. // @grant none
  6. // @version 1.0
  7. // @author GreasyBastard
  8. // @license AGPLv3
  9. // @description Simply sets and updates page title to search terms.
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function removeDuckDuckGo() {
  16. var currentTitle = document.title;
  17. var newTitle = currentTitle.replace(/\s*at DuckDuckGo\s*$/, '');
  18. if (newTitle !== currentTitle) {
  19. document.title = newTitle;
  20. }
  21. }
  22. removeDuckDuckGo();
  23. var titleObserver = new MutationObserver(function(mutations) {
  24. mutations.forEach(function(mutation) {
  25. if (mutation.type === 'childList') {
  26. removeDuckDuckGo();
  27. }
  28. });
  29. });
  30. var titleElement = document.querySelector('title');
  31. if (titleElement) {
  32. titleObserver.observe(titleElement, { childList: true });
  33. }
  34.  
  35. function modifyFormMethod() {
  36. var form = document.querySelector('form[action="/lite/"][method="post"]');
  37. if (form) {
  38. form.method = 'get';
  39. }
  40. }
  41. modifyFormMethod();
  42. var formObserver = new MutationObserver(function(mutations) {
  43. mutations.forEach(function(mutation) {
  44. if (mutation.type === 'childList' || mutation.type === 'attributes') {
  45. modifyFormMethod();
  46. }
  47. });
  48. });
  49. formObserver.observe(document.body, { childList: true, subtree: true, attributes: true });
  50. })();

QingJ © 2025

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