Intercepting chrome-extension://*/?q=<input> in chrome extension - google-chrome-extension

So I am using the omnibox in my extension, and after a user enters something in the omnibox, it becomes part of the extensions "history" (which would be a nice feature). However, when the history entry is clicked on, it goes to "chrome-extension//?q=, and that returns an Error 6 (net::ERR_FILE_NOT_FOUND). Is there any way to remedy this situation, either by allowing this to act as it did the first time, or just by disabling the history?
EDIT: so it turns out one cannot inject content scripts into chrome-extensions (even though the documentation says you can (they're fixing this hopefully)
Any other advice is still appreciated, but I've become less hopeful that this can be done.

Related

Creating a floating menu that pops like normal menu but appears at mouse position

Some context
I've recently switched to ubuntu budgie (from unity), and I am really tired of the Plank/panel menu combo. I cannot find a setting that suits me, because depending on my screen setup, there's always something in the wrong place.
I am literally unable to show the menu on certain edges if I activate auto-hide, and if I don't activate it, it's not nice at all, to the point that I have removed the plank thing altogether. (Am I having strange bugs on this OS, or is it really messy?)
My idea
With great frustrations come new ideas. I thought again about one I had in the past. I would like to have a circle menu that pops around my mouse cursor when I press a given key combination (very much the kind of thing you would find in some games).
The main use case is to get "pined" application shortcuts easily when I need them, but perhaps other things would fit well with them (commands ...).
Questions
So my questions are:
Does such a thing already exist?
If it doesn't, is it difficult to realize? (How much time, complexity, ...)
What tools/libraries are needed for such a project? I know I'll find plenty of explanations on the gnome developer website but I could really use some more help.
Since you mention a buggy behaviour on Plank, depending on the screen configuration, I suspect you are suffering from this bug. In short: Plank's returned values for the space it needs are not always correct in multi monitor setup.
A neat option to replace at least part of the functionality is Ulauncher, by default called from a shortcut, but you could trigger it from anything that is capable of running its command.
Since Ulauncher's window simply identifies in the window list, you can easily write a script to move it to the current mouse position.
In case you'd need any help in that, just leave a comment.
Not sure if you are also referring to quick access of the window list, but for that you could use the Window Previews applet, or even the Workspace Overview applet, so life without Plank is possible.

Can a Chrome extension change its large (new tab page) icon?

My question is along the same lines as this: Change the Chrome extension icon
But I'm wondering instead about the large icon of the extension on a new tab page. Can it change itself based on data? All I have in mind is a simple countdown-calendar (as in, the whole point of the extension is to be a big ol' number on your new tab page), so the actual code wouldn't have to be very long, if icon-changing is possible. (It wouldn't even need to sync or connect to the Internet for any reason.)
My strong hunch is no, because I've never seen an extension do so, and I would expect that if it could, my Chrome's Gmail button would probably display the number of new messages or something. But I figured it didn't hurt to ask.
PS: I've never created a Chrome extension, I just had that idea for one just now. Anyone reading this can feel free to do it themselves, but otherwise I'll make it when I get the time, as a learning exercise.
Only apps (not extensions) can have an icon on the New Tab page (NTP).
This icon have to be declared via the icons property in the manifest file, and cannot dynamically be updated.
I can imagine two ways to get a dynamic icon on the options page:
Create an extension that replaces the New Tab page. Have a look at the docs for Override Pages.
Create an extension that uses the chrome.management API to enable/disable apps. This method might work for your personal setup, but it requires a new App for each icon. This feels a bit hacky, but hey, it might work.

Writing a Chrome extension that highlights "current" line

I have an idea for a useful tool but I have no idea where to start. (I apologize for the vague nature of the question, but I do think it can be answered in a specific way and therefore is appropriate for SO.)
Here's what I'm after in a nutshell: a Chrome extension that darkens/shades the whole viewport except for the "current" line, i.e. the line you're reading. (I explain momentarily how the "current" line is determined.)
Pretend the line outlined in red is the highlighted line and everything above and below is grayed out. (My mockup sucks but I'm working with limited tools right now.)
When the page loads and you turn on the extension, the "current" line is the first line of paragraph text. To go to the next line, press the down arrow. Ideally, your highlighted line is in the exact middle and the rest of the page "slides underneath" to the extent that it can so your eyes don't have to move.
So here's my question: if you knew HTML/CSS/JavaScript well enough but you'd never written a browser extension, where and how would you start this? Do a plain JS POC first? Build the POC as an extension?
To be clear, this isn't a "plz how i write ecomerce site" question where I'm asking you to spoon feed me the whole thing. I'm just asking what you'd do as the first step. I realize this is a non-trivial undertaking. Thanks in advance.
If you know HTML/CSS/Javascript well enough to get the effect you after, then getting started with a Chrome extension shouldn't be hard. Just read the Chrome extension developer documentation. There are loads of example extensions as well.
You basically need to make a package directory, containing a manifest.json, and specifying a single "content script" which would contain all your code.
It could make sense to start out developing based on a bookmarklet that injects a script tag (with file:///path/to/yourscript.js) because I think that would be slightly faster wrt loading new code, resulting in a slightly faster development cycle. You could also set up a dummy page to always include this particular script tag so you only have to reload that page to see your change. Even fancier: Use http://livereload.com/
Otherwise you need to instruct chrome to reload the extension manually after each change in your code.
You may like to use Extensions Reloader for easier reloads.
I like the idea by the way!

How to make Google Chrome extension sample work?

Recently I decided to write a very simple Google Chrome extension. All it's going to do is to hide some DOM-elements from the web-page using JavaScript when user presses the extension's button.
Since I knew nothing about Chrome extensions, I started reading tutorials, and I came across this Google's sample: A browser action with no icon that makes the page red
This sample is really close to what I want to make. The problem is that I can't make it work. Whenever I load the extension in Chrome, I can see the button of this extension, but when I press it - nothing happens. Sample doesn't work, probably I should know something I don't know yet.
And before you started asking me:
Yes, I tried restarting the browser;
I use the newest version of Chrome.
Thanks for help.
If you open up the sample zip... find backgrond.js... edit.
Find the line that says:
null, {code:"document.body.style.background='red !important'"});
and remove the "!important". so it should read:
null, {code:"document.body.style.background='red'"});
That is it. just save and reload the extension, should work (unless the page has an !important flag set to the background).
I am afraid I don't know why the "!important" tag doesn't work but I have never been able to get it to work in an extension. Hopefully someone else here will be able to give an explanation and maybe a work around.
I think I can help bring some clarification to the "!important" override attribute causing the extension to break. Though I am not 100% I believe that this attribute is not allowed for issues involving security complications. I have a link to another SO thread that may help clarify this as well.
My CSS is not getting injected through my content script
I'm assuming from reading this article that you must either use the !important override when content scripts specified in the manifest file. Otherwise if the css is being injected !important is not required. Again not 100% on this.

Ideas for educating users into typing url in address bar instead of google

My Google analytics shows the second most used keyword to access my site is the url of the site. This doesn't particularly surprise me, but I wondered if any of you have tried educating your users out of this (i.e. detecting search term from referrer and showing a popin encouraging them to create bookmarks etc.) or is it just a waste of effort or likely to annoy.
UPDATE
I was watching someone the other day and discovered one possible reason why people do this. If you try clicking in the address bar and click twice instead of once, then type your url, you get a big mess. Far easier to type into the nice empty google search box (which is also selected by default). So basically you have the choice between:
Type > Enter > Click
or
BadClick > Type > Enter > "Bugger!" > Click > Type > Enter
Similarly, Microsoft noted long ago that many people just type search queries into the address bar. If there are essentially between two and four unlabeled text boxes on a browser window (address bar, search box, maybe Google start page, toolbars, etc.) don't expect the user to find the right one when they should.
As long as they end up where they wanted to they couldn't care less.
Google Chrome did the right thing imho by merging at least the search and the address bar again.
for most people, google is the internet.
Focus your efforts somewhere else, like providing good contents. It does not matter how they get there.
Good luck :) Most of internet users may even not realize if the address bar gets removed from their browser. Typing a URL is far too technical.
I'm not sure anything can be done. Users are known to be extremely stubborn in their habits.
One my fellow googles for the login page of his online-banking system, being too lazy to type it in or bookmark it. That scares me a lot. It only takes for someone to manipulate search results even for a day or so to hijack the credentials.
I suggest you ignore the matter. With luck, if they google enough for your site, then google will start to show the name of your site in suggestions as your type which is rather nice.
I've tried to encourage the use of a browser at work to access the data I put on the company intranet. It's proving difficult — they would much rather open My Computer and drill down through many levels of folders, while muttering 'Where was that file? What was it called again?'
I prefer the idea of web pages on an intranet site, with images, hyperlinks, etc, but I have to be careful not to use the term 'browser' since people don't really know what it means. For example, I demonstrated the site to one colleague by telling her to start 'Internet Explorer', then I typed the URL, rather than explain it to her. When the web page opened, she said 'Oh wow, what program is this?'
I've gone to some trouble to use 'friendly URLs' — no complex query strings, but it was probably a waste of time. I'm sure no-one types them in and uses bookmarks/favorites instead.
If the address bar disappeared, it wouldn't be missed by the majority of Internet users, and there's a Google/Yahoo/whatever search tool in the corner of each page.

Resources