Google Homepage Script - Add or replace 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 - Add or replace 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. var text = "Harry Potter is enjoying his life... most of the time";
  14. if (window.location.href.startsWith("https://www.google")) {
  15. var langdivtag = document.getElementById("gws-output-pages-elements-homepage_additional_languages__als");
  16. if (langdivtag !== null) {
  17. langdivtag.innerHTML = text
  18. } else {
  19. var x = document.getElementsByName("q")[0];
  20. x.setAttribute("placeholder", text)
  21. } }
  22.  
  23.  
  24. // Your code here...
  25. })();