You will need to install a user script manager extension to install this script.
This userscript auto-agrees to the cookie warning dialog. The dialog should only appear once.
The popup is not hidden, will flash while it is dismissed by the script and disappear for ever (until you clear your cookies). It's on purpose in case the script fails and leaves you in a state where google constantly asks the same question.
If you are really fed up with cookie warnings on many sites, I suggest installing an extension that handles it automatically (including for google). I can suggest one that works well for chrome and firefox. On the add-on/extension store, search for
I don't care about cookies
Note: google regularly changes the style names. This could break the userscript. Please post a comment if this is the case for you.
2021/04/02: Google has modified the display of the dialog. The script has been fixed. Report here if it still fails for you.
The new dialog is a little bit different. The remark on Firefox and the userscript managers can be disregarded if the older version of the dialog is no longer used by google.
Note for Firefox users: If you are using tampermonkey as userscript manager, this script won't work. There is a bug in Tampermonkey and Tampermonkey beta - as well as Greasemonkey - which prevents the script to be executed on the popup. Other scripts from other programmers might not work properly too; use the solution below.
Solution for Firefox: As far as I know, only one userscript manager works properly: ViolentMonkey. Feel free to install it to run this userscript.
For more userscripts, styles, extensions, tips, ..., visit my programming page.