Google Chrome extension: use Javascript inside webkit notifications?

I followed the Google Chrome Extensions Developer's Guide and so far was able to create the extension using a browser action without a popup that triggers an HTML web kit notification.

The fact is that this HTML file contains action buttons, links, and javascript, but none of them seem to respond.

Is this behavioral behavior, or is there a way to embed javascript / links / buttons in these webkit notifications?

EDIT:

Here are some new ideas on the topic:

Javascript

Here is the HTML notification page that does not work:

<html> <head> <script> alert("hey"); </script> </head> <body> content </body> </html> 

As a result, the notification is all empty; the text "content" is not displayed.

But if I remove the "warning", the text "content" will appear.

At first I thought that Javascript was blocking the page display correctly, but I tried something else:

 <script>document.write("content");</script> 

This javascript command is correctly executed and displays the text "content". We can then assume that Javascript is enabled even in webkit desktop notifications, but the alert function is disabled and breaks the visualization of the notification page.

References

Some links work, some do not. Here is a short list of the ones I have tested so far:

 <a href="http://www.google.com/">Link</a> # => Doesn't work <a href="http://www.google.com/" target="_top">Link</a> # => Doesn't work <a href="http://www.google.com/" target="_parent">Link</a> # => Doesn't work <a href="http://www.google.com/" target="_blank">Link</a> # => Works (new tab) 
+4
source share
2 answers

Everything is explained in the Chromium Desktop Notification API Specification , which clearly states that:

If the user agent implements createHTMLNotification, it should display HTML notifications as independent viewing contexts that are equivalent to the functionality of any other HTML web page, except for the following properties:

  • Notification cannot be moved . The Location attribute of the window object in the notification context should be read-only. All links should open in new contexts without notice.
  • If the close () function is called in a window object in the context of a notification in response to a user gesture, the user agent must act as if the user has closed the notification, including all necessary event processing.
+2
source

UPDATE: createHTMLNotification() been removed from the project specification as well as from Chrome , so this will no longer work.

The immediate task is the onclick handler in the entire notification window. This is less searchable (not like a link), and I did not check if it is possible to go to the link from it.

+2
source

Source: https://habr.com/ru/post/1310619/


All Articles