add a TAB specific notification (jquery ui dialog) in chrome extensions? - google-chrome

I a writing an extension with a background.js file that compares the url (every time it changes) with an internal list. If it finds a match, I want to have a popup that shows the user various options.
Currently, as part of my quest to understand extensions, when you visit one of the urls in the list it pops up a Desktop Notification. That is definitely NOT what I want since it is hard to customize and is not specific to the tab.
My ultimate goal is to have something similar to the jquery ui modal dialog. I've tried searching, but the similarity to Desktop Notifications makes it difficult. Is it even possible?

after reading more on how to inject JS into a page, I stumbled across a simple way that does not use the content_script paremeter (I don't want to add code to every page and the list of "matching" urls is both long and dynamic). This code can be run from the background.js file (as long as I insert "http://*/" and "https://*/" in permissions inside manifest.json):
chrome.tabs.executeScript(tabId, {code:"alert('this url matches your list');", runAt:"document_start"});
I wrapped that in a function that only gets called AFTER finding out if the url matches one on my (long) list of urls
technically, this answers my question...it would be possible to change that js "code" that I am executing so that it looked a lot nicer and functioned the way I wanted it to...
BUT, that seems like a lot of work, and adding jquery doesn't seem to be an options...anyone have a different method that is simpler?

Related

Adding an in-page search and display within a Mediawiki page

I have been requested to add some functionality to a Mediawiki page. I am learning MW as fast as I can. We have a MW page with a very large wikitable of bibliographic data. The data is also kept in an external Excel file. It has been requested to add an input field and button so that visitors can search that bibliography and redisplay just the rows that contain a match for the search. I've looked at a lot of extensions and have tried to work out how I could patch together this functionality (Maybe External Data and URLGetParameters but how to do the input field?) I've thought about using an Iframe for the whole thing, and simply do it in PHP using the external spreadsheet but then the information in the IFrame is not visible to the MediaWiki search, yes? Perhaps Javascript/JQuery but I haven't worked out how to execute that on a MW page yet. Does anyone know a proven path for doing this type of thing so I can possibly cut out some of the dead ends I am investigating?

Fill in webforms / auto login in AutoHotKey in Crome

I want to open a couple of webpages. Some require User-name password. Others requires to fill in certain files in a webpage.
There are multiple ways for AutoHotKey to fill in web forms, but all are based on "com" which only works with IE
I've googled a while for examples in what fill in webforms and/or login in Crome, but found non so far. Does anyone has an example of an AHK script what fill in fields in a webpage/form
First off I'm going to start by stating that you should have included code, after all this is a code review site rather than a "Hey I need codez" site...
Now to answer your question:
You are correct, COM Objects are the best way to interact with Websites in Windows, it's dead simple and just works (in IE). Since Chrome doesn't support COM, you are left with only working with within the limitations of the browser accepting keystrokes.
Your best shot is to use the Send command to navigate to your target field (I believe sending Tab multiple times when the window is active should work) and than Send the data you wish.
I would also suggest looking into #IfWinActive and BlockInput so that you won't accidentally send an inappropriate key stroke while filling in these forms.
There may be better options for this, such as KeePass or the like. Also it's generally not a good idea to store passwords in plain text, IE within an AHK Script.
Correct, it's not possible to use Com objects with Chrome, however this site has a ton of entry level how-to's to get started with using the com object in IE. This includes how to send specific fields text (without using the send or sendinput commands), and how to triggers onclick events on existing elements (without clicking on them).
This was were I started when I needed to learn how to interact with the com object.
https://autohotkey.com/board/topic/64563-basic-ahk-v11-com-tutorial-for-webpages/

Change icon based on posts from another page

Apologies if this has been asked before. I searched and couldn't find anything.
I have a basic landing page website that has an icon that links to "Hot Alerts", ie notifications of system outages. What I'm wondering is if there's a way to either change the icon or add a notification bubble (similar to Facebook notifications) if content on a Sharepoint blog has been updated in the past "X" hours.
Here's the icon I'm referring to:
Hot Alerts Icon
I've found examples of how to style the icon with CSS, but those all require manually entering the number of new notifications.
What I need is a way for the icon to "check" the sharepoint page for its most recent post when the landing page is loaded.
Most of my colleagues use Internet Explorer, but Chrome is creeping into the workflow.
What you need to use it the Javascript Object Model (JSOM). You will be able to read lists (for new posts) upon page loading and then showing or hiding the icon. A lot of example code to read lists can be found on SO.
If you want to use a 'bubble', take a look at sp.ui.notify (https://msdn.microsoft.com/en-us/library/office/ee550701%28v=office.14%29.aspx) methods to show an overlay notification popup on the page.
It's very unlikely this can be done with pure CSS. Any of the following languages will provide suitable solutions: JQuery, JS, PHP.
In PHP, you could use $_GET to place the variable in the URL. So one page would use $_GET to post the variable to the URL and the PHP file loading the page would use it to retrieve the variable from the URL.

How extension get the text selected in chrome pdf viewer?

I wrote a chrome extension - english dictionary. You select word, the definition appears.
It works well, but I counter a problem. It seems there is no api of chrome pdf viewer supplied by google.
How can I get the word when i select a word in pdf using chrome pdf viewer?
I will be appreciate if you could help me.
You can get selected text using the context menu. In your background script, adding these lines will allow the user to right-click and do something with the selectionText.
chrome.contextMenus.create({id:"lookup",title:"Lookup %s",contexts:["selection"]});
chrome.contextMenus.onClicked.addListener(function(sel){
console.log(sel.selectionText);
});
Grabbing this text works fine with PDFs, whether part of the extension, or not.
However, you cannot inject a script into a page starting with "chrome-extension://". If this is how your extension works, that will not be (directly) possible. But getting the selected text, and doing something with it still very doable.
As an alternative to requiring script injection, see the notification api, which allows a small message to popup, which could contain the definition of the word.

How to access input fields in a page from a Chrome extension?

I am trying to make a Chrome extension for personal use that makes all the password fields type="text", so I can see the clear passwords. (I know that I can probably find something like this in the Chrome store, but it's something I want to do myself).
I am however having a hard time accessing the actual page content (the page I'm viewing in the tab). If I do
document.getElementById('text')
this selects the element from background.html not the page I'm viewing. How can I access the actual page?
Also, is there a way I can include an external javascript file so I can use functions from there?
You would need to use content script - javascript file injected into an actual page with access to DOM and events.