Universal Search Enhancer

Adds a universal search bar to all websites for quick searches on Google, Wikipedia, or YouTube.

目前为 2025-01-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Universal Search Enhancer
  3. // @namespace https://itzmehuman000.github.io/
  4. // @version 1.0
  5. // @description Adds a universal search bar to all websites for quick searches on Google, Wikipedia, or YouTube.
  6. // @author DUSTIN
  7. // @license MIT
  8. // @match *://*/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const searchContainer = document.createElement('div');
  16. searchContainer.style.position = 'fixed';
  17. searchContainer.style.top = '10px';
  18. searchContainer.style.right = '10px';
  19. searchContainer.style.zIndex = '9999';
  20. searchContainer.style.backgroundColor = '#ffffff';
  21. searchContainer.style.border = '1px solid #ccc';
  22. searchContainer.style.padding = '10px';
  23. searchContainer.style.borderRadius = '5px';
  24. searchContainer.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)';
  25. searchContainer.style.fontFamily = 'Arial, sans-serif';
  26.  
  27. const searchInput = document.createElement('input');
  28. searchInput.type = 'text';
  29. searchInput.placeholder = 'Search something...';
  30. searchInput.style.width = '200px';
  31. searchInput.style.padding = '5px';
  32. searchInput.style.marginRight = '5px';
  33. searchInput.style.border = '1px solid #ccc';
  34. searchInput.style.borderRadius = '3px';
  35.  
  36. const searchDropdown = document.createElement('select');
  37. searchDropdown.style.padding = '5px';
  38. searchDropdown.style.border = '1px solid #ccc';
  39. searchDropdown.style.borderRadius = '3px';
  40.  
  41. const platforms = [
  42. { name: 'Google', url: 'https://www.google.com/search?q=' },
  43. { name: 'Wikipedia', url: 'https://en.wikipedia.org/wiki/' },
  44. { name: 'YouTube', url: 'https://www.youtube.com/results?search_query=' },
  45. ];
  46.  
  47. platforms.forEach(platform => {
  48. const option = document.createElement('option');
  49. option.value = platform.url;
  50. option.textContent = platform.name;
  51. searchDropdown.appendChild(option);
  52. });
  53.  
  54.  
  55. const searchButton = document.createElement('button');
  56. searchButton.textContent = 'Search';
  57. searchButton.style.padding = '5px 10px';
  58. searchButton.style.border = 'none';
  59. searchButton.style.backgroundColor = '#007bff';
  60. searchButton.style.color = '#fff';
  61. searchButton.style.borderRadius = '3px';
  62. searchButton.style.cursor = 'pointer';
  63.  
  64. searchButton.addEventListener('click', () => {
  65. const query = searchInput.value.trim();
  66. if (query) {
  67. const selectedPlatform = searchDropdown.value;
  68. window.open(selectedPlatform + encodeURIComponent(query), '_blank');
  69. }
  70. });
  71.  
  72. searchContainer.appendChild(searchInput);
  73. searchContainer.appendChild(searchDropdown);
  74. searchContainer.appendChild(searchButton);
  75.  
  76. document.body.appendChild(searchContainer);
  77. })();