Is it possible to put links in chrome desktop notifications - google-chrome-extension

I'm making a chrome extension which displays desktop notifications on particular events. I am receiving and displaying the desktop notifications just fine, but the problem comes when I try to put attribute tags into notification. Instead of being the text as tags to be appended to the notififcation's DOM, Chrome seems to just interpret them as plaintext, resulting in the content of the notification being just html source code.
Is there any way that I can have the body of my messages be appended as HTML instead of just text or am I just out of luck?

It used to be possible, but now it's not. But you could use a "Rich Notification" and put the link on a button. See https://stackoverflow.com/a/13328513/488287 for details.

Related

How can I prevent an iframe displaying an email to load images and other email trackers?

We have a web admin panel in which the agents can see conversations with customers.
Those conversations are the result of importing normal emails thru an IMAP connection. We grab the "untouched" mailbox files and we store them in a database. Then we post-process the files to index by "from", "to", "date" and so on and so forth.
Up to here, okey. We can seek all the emails involved with a client and render them at will.
Then when the agent looks for a customer in the web admin panel and opens it, the full email conversation appears. And we display the HTML version of the email within an iframe (or the text version if the html version is not there). 90% of the customers send HTML.
What happens? Upon the agent opening the email in our web, the iframe loads the "full html" and renders it. This makes "remote loading" (images, sounds, styles if so, and whatever) to be downloaded. This allows customers to "track" if we opened the email by appending tracking id's to the assets (typical http://track.example.com/image.jpg?id=123456789)
I've tried the "sandbox" attribute of the iframe html tag with no luck (it still downloads the images).
Question
How can I programmatically tell the iframe to not load ANY remote content, and just render the initial HTML without any remote call?
Mozilla's iframe documentation listing all available attributes for the is here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
If you look at "sandbox" there is no restriction specific to image or other includes, just restrictions on things like running JavaScript. There are no other attributes that would restrict images and includes.
To solve the problem of images and includes in your HTML you will need to filter the HTML either at the server before sending it or in the client after it arrives.
Server:
Before storing it into the database.
In the code that retrieves the HTML and returns it to the iframe.
Client:
Use AJAX to fill the iframe with the HTML, with code that filters a
response. With this approach you could also use a div instead of an
iframe if that works better for your layout.
If all of your users will use Chrome or Firefox, you could look at writing a browser extension

chrome desktop notifications get text

I have chrome plugin, that checks given URL and use 'get' method to check the return HTML code. if thee are errors - chrome notifications will pop. I want to create a button and whenever the notification button will be clicked, an alert will pop with the notification text.
I am not able to find any source of information on how to do this, and I will be happy if someone can help me with this
I've already try to search examples, on the web and on Google's website but without any luck

xpages File Download control - open instead of save?

When you click on the link for an attachment in the File Download control in XPiNC, you are promoted to save the attachment. Is it possible to configure the File Download control to open the attachment directly instead of prompting the user to save it? We're using 8.5.2 FP3.
Handling of an "attachment" is primarily done by the Browser (XPiNC being a firefox browser inside Notes). If for example, a PDF plugin is installed in the browser and the servers sends the corresponding "application/pdf" mime-type with the file, the browser uses that plugin to display the file. The correlation between mime-type and plugin or external application in the browser is something the server/webapplication can not influence.
What you can do on the server side is sending the mime-type "application/octet-stream" instead of the one corresonding to the file type, causing the browser to display the "Select application or download" dialog. So in Xpages, you would have to redirect the download through a XPage, where you set the corresponding HTTP Headers as shown in Set cache headers on an XPage and How to force PDF files to open in browser?
I haven't used the file download control or XPINC, but it is definitely possible to make your xpage or view control open an attachment directly. This method bypasses the download control.
Please see this post from Stephan Wissel: http://www.wissel.net/blog/d6plinks/SHWL-86QKNM, which gives you some SSJS that you can use to build the URL. You can use it in the onClick method of a button. You are essentially duplicating the functionality of the download control in a way that does what you want it to do.
If you want to do the same thing from a view control, then see this post: http://notesspeak.blogspot.com/2013/02/how-to-launch-attachment-from-view.html
Note that different browsers behave slightly differently but it works in all the majors.
Michael,
Here is code I used:
var unid = rowValue.getUniversalID()
var url = getAttachmentURL(unid, "storetransfer.pdf", "Testing//test.nsf")
url = "/" + url + ";"
view.postScript("window.open('" + url + "', '_blank', 'height=120,width=650,top=10,left=10,resizable=yes');");
I did modify Stephan's code a bit since my data is in a different NSF than my code. You probably know this but the view.postScript allows you to call clientside javascript from SSJS. It always is the last thing to run, hence the name. This is the same code from the Notesin9 video mentioned in the comments. I just tested this and it works like I think you want, but in firefox it does try to block the popup, and then has to push "open". Hope this helps.

Calling chrome.browserAction.setIcon from content script the way it is done in background script

I am making an extension for chrome. It fetches data from webpages and emails it via local email client. I have a toolbar button which user has to click to invoke the script.
My script works for a few selected urls. I want my toolbar button to change icon based on whether the url is among our list or not. For example for site1 it should be redicon.png and for site2 it should be blueicon.png. I can change button icon using chrome.browserAction.setIcon. But the problem is that this API does not work in content script. It works fine in the background.js file but not in content.js. Kindly tell me how to achieve this.
I know using pageAction instead would do the trick but my client requirement is that the toolbar icon should change rather than appear and disappear.
What you need to read about is message passing. You are right, content scripts have limited chrome API. However, you can contact background page from content script and tell it to execute anything from chrome API for you. First, you need to create a listener on a background page that will be waiting for messages and then send a message from a content script.

Google Chrome extension modifying page request

Is it possible to catch the request of a page before it is sent out? I would like to check and modify the data sent out. For example if I have a text box on a page and the form was submitted I would like to get to the data of the text box using the extension modify it and then send it on it's way.
If any one can point me in the right direction that would be grate
Chrome has chrome.experimental.webRequest API module which allows to catch web requests before they are sent, but from the docs it doesn't look like you can modify them, just observe.
I think you would be better off injecting a content script to pages and listening to onbeforesubmit event on forms.

Resources