Chrome notification not showing with Tampermonkey Chrome notification not showing with Tampermonkey google-chrome google-chrome

Chrome notification not showing with Tampermonkey


Per the GM_notification documentation, GM_notification's image parameter requires an image.
'bar' is not an image, so the GM_notification call fails (silently).

Granted, it would be nice if there was an error message, but currently Tampermonkey does not provide one. (Feel free to file a bug report.)

Also:

  • Those (function wraps are completely unnecessary, and just clutter/complication.
  • Ditto the window.jQuery.noConflict -- when @grant none is not in effect.
  • No parameter is passed to the onclick callback so giving it console.log has no effect.


Here is a complete working script with the above errors corrected:

// ==UserScript==// @name        _Notification test// @match       *://YOUR_SERVER.COM/YOUR_PATH/*// @match       https://stackoverflow.com/questions/51769201/*// @grant       GM_notification// @require     http://code.jquery.com/jquery-1.12.4.min.js// ==/UserScript==GM_notification ( {title: 'foo', text: '42'} );


With a valid image:

GM_notification ( {    title: 'foo', text: '42', image: 'https://i.stack.imgur.com/geLPT.png'} );


With a useful onclick:

GM_notification ( {    title: 'foo', text: '42', image: 'https://i.stack.imgur.com/geLPT.png',    onclick: () => {            console.log ("My notice was clicked.");            window.focus ();    }} );