Add 'Google' button to duckduckgo.com

Adds a 'Google' button below the search box to repeat the search at google

当前为 2018-10-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Add 'Google' button to duckduckgo.com
  3. // @description Adds a 'Google' button below the search box to repeat the search at google
  4. // @encoding utf-8
  5. // @namespace google_button_duckduckgo
  6. // @match *://duckduckgo.com/*
  7. // @grant none
  8. // @run-at document-end
  9. // @version 0.0.1.20181024123740
  10. // ==/UserScript==
  11.  
  12.  
  13. (function() {
  14. console.log('running');
  15. function searchOnGoogle() {
  16. document.location = "https://google.com/search?q=" + document.getElementById('search_form_input').value;
  17. }
  18. var elem = document.getElementsByClassName("header__content header__search")[0];
  19. if (elem && !document.getElementById('search_on_google')) {
  20. var div = document.createElement('div');
  21. div.id='search_on_google';
  22. var button = document.createElement('button');
  23. button.innerText = 'Google';
  24. button.onclick = searchOnGoogle
  25. div.appendChild(button);
  26. elem.appendChild(div);
  27. }
  28. })();