Clear selection in WebKit2 Web Extension without JavaScript - webkit2

I want to clear the selection from a web extension.
There is a signal selection-changed, but there does not seem to have a way to clear the selection.
I tried creating a WebKitDOMRange but it seems there is no way to set this new range in the document.
And it does not seem to have a way to get the current range.
How can I clear the selection from a WebKit2 web extension without using a JavaScript string?

WebKit2 seems to have an unstable API that does not appear in the documentation.
I was able to get the current selection with the webkit_dom_dom_window_get_selection and clearing it with webkit_dom_dom_selection_empty

Related

In order to add new functionality to existing Firefox clients, do I need to create an extension or a plugin?

More specifically, the idea is to allow the user to open Firefox, highlight a word on a web page, right click on it, and have an additional option that, when selected, calls c++ code that does something with the input string (must call C++ code, unfortunately), and displays a dialog box showing the result.
I'm still not sure if in order to implement this functionality I need to create a Firefox plugin or an extension. Can someone point me in the right direction?
Also, if someone can show me sample code in order to get me started that would be appreciated. (XPCOM, which I'm not even sure is what I should be using, seems a bit complicated for this seemingly simple project.)
You need a regular Firefox extension. It can add an item to the context menu, NPAPI plugins cannot do this. When it is clicked it can get the selected text and send it to your binary library. The best way to call functions in this library is js-ctypes, XPCOM is not required.

Is it possible to set config settings on Firefox from a Addon

I'm looking for a way to print from web without prompting the print dialog (I just made the question).
I found This method for Firefox and it seems to work, but it obviously will affect all websites. So I'm thinking of developing a Firefox Addon that makes this configuration to affect only specific websites.
I don't know nothing about building Firefox addons, but if it's possible to change settings this way I will learn how to do it.
So my question is.. Is it possible to set config settings on Firefox from a Addon and for specific websites?
Thanks a lot.
If you are going to develop a Firefox addon you could "easily" replace the print button and delegate to the standard print action on normal websites. For a list of URLs, i.e. your web site, you temporarily set print.always_print_silent to true and be done with it.
For modifying a preference in an addon you would something like this:
// Get the "accessibility." branch
var prefs = Components.classes["#mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch("accessibility.");
// prefs is an nsIPrefBranch.
// Look in the above section for examples of getting one.
var value = prefs.getBoolPref("typeaheadfind");
// get a pref (accessibility.typeaheadfind)
prefs.setBoolPref("typeaheadfind", !value); // set a pref (accessibility.typeaheadfind)
(taken from this snippet).
One way is to provide your own implementation of the printing prompt service. You could then inspect the window being printed and turn on silent printing if you want to bypass the print dialog. You might need to retrieve the original service to handle the cases that you don't want to. I couldn't find much documentation but there's some related documentation here.

Alternative til jQuery Lazyload

I have searched and searched, but didn't find what I was looking for, so sorry if it's already there. I did a photo blog for a friend and used to implement jQuery Jazyload (http://www.appelsiini.net/projects/lazyload) to load all the pictures along the way, however, it doesn't work in all browsers anymore and he stopped developing it. I heard of http://www.sebastianoarmelibattana.com/projects/jail/, but it will need a lot of extra text and code when you have 500-1,000 pictures on one site. Also I want to be able to load the images lets say 1000px, before they appear in the window.
Do anyone have suggestions/solution or else, to get the problem fixed?
You can view his site here: www.theblackguido.com (NSFW)
Thank you in advance.
Kristian
It is the part of automatically removing image src which does not work anymore. Version 1.5 released Dec 23, 2009 provided alternative where you must alter HTML and store image url in original attribute. I renamed it recently to data-originalto be HTML5 friendly. I also updated to documentation which better explains how to use it.
But yes. The way Lazy Load used to work is not possible anymore. Before you could just drop in the JavaScript and it handled everything automagically. Due to changes in new browsers you now must alter the HTML.
PS. Lazy Load is not dead. It was just orphan for a while.

How do I disable Firefox's "Search for text when I start typing" on pages with keyboard shortcuts?

Some web pages such as GMail and Reddit(with the Reddit Enhancement Suite) have useful keyboard shortcuts that I'd like to use. However, whenever I start typing on one of these pages, the first onkeypress event fires, but then the "Search for text when I start typing" search bar opens and blocks further keys.
I don't want to disable "Search for text when I start typing" as I use it on most other web pages. Is there any way to selectively disable it, or to make a keyboard shortcut/bookmarklet to toggle it?
To disable this in firefox, just go to "Options->General Tab->Browsing and disable "Search for text when I start typing". More info here . This is very useful in some cases, for example when you try to play WebGL games or when using pages like Gmail or Protonmail that have their own kb shortcuts.
UPDATED to version 73.0.1- In previous versions of Firefox this is in "Tools->Options->Advanced->General Tab" or in "Preferences->General->Browsing"
This is still an issue huh? I love this feature but It also bothers me every now and then. There are some pages that get it right. I never dug into how they do it. For instance:
zty.pe - JS browser typing game. Would be pretty bad if typing caused searching here. It actually captures the keys just when the game starts and NOT by default on the page.
That is not Firefox or any other browser feature. To do this, you have to write server and client side code.
Catch text that user types into input, and send it using preferably AJAX to server-side script. Then server side script should look up for matches in DB (some search engine), and return possible combinations. All you have to do on client side (JS) is to show returned results in some nice way - like in google - you can use for example simple html lists, but you have to code some css to make it look properly. Also nice feature is to code JS to work on up/down keys and enter for selecting element (it should also work for mouse).
It's not very simple to do by yourself, but you have now idea how to do it. You could also google for some scripts - surely there is something :)
Good luck!

How to make a site-lookup addon for Firefox?

I'd like to create an addon for Firefox that would enable me to search a particular site by selecting text on one site and choosing to search another site by selecting that option in the context menu.
I already have an extension like that in my browser - the Wikipedia Lookup extension. Basically, I want the exact same functionality but which will send the search text to a different site.
I'm completely new to Firefox addons, so can somebody tell me what's involved in this? Or point me at a site with a list of instructions to do a plugin like this? I can see examples on how to make a Hello World kind of plugin but I can't see how to extend that example into what I need. Thanks.
Have you considered opening the Wikipedia extension source and modifying the pointer from wikipedia.com to the other search site? This is assuming you're using Windows Vista or higher. The source code should be located at:
C:\Users\YourUserName\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default\extensions\something#wikipedia.com\chrome\content
You would then have to modify the source code inside to change the pointer, and the POST variables string to match that of the site you will be using.
I hope this at least points you in the general direction!
-Alex

Resources