Google Homepage Script - Prompt For Text

Show a string in Google below the search bar if "alternate language notice" exists, otherwise: Text in searchbox

  1. // ==UserScript==
  2. // @name Google Homepage Script - Prompt For Text
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Show a string in Google below the search bar if "alternate language notice" exists, otherwise: Text in searchbox
  6. // @author spookyahell
  7. // @match https://*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. if (window.location.href.startsWith("https://www.google")) {
  14. var langdivtag = document.getElementById("gws-output-pages-elements-homepage_additional_languages__als");
  15. if (langdivtag !== null) {
  16. langdivtag.innerHTML = prompt("Enter any text here and it will wind up on Google, below the searchbox", "Harry Potter");
  17. } else {
  18. var x = document.getElementsByName("q")[0];
  19. x.setAttribute("placeholder", prompt("Since below searchbox is not available for you, we will set the searchbox hint instead", "Harry Potter"))
  20. } }
  21.  
  22.  
  23. // Your code here...
  24. })();