Firefox extension get text in context menu (javascript) - javascript

The first think i try was to get the selected text, but that is impossible in Firefox.Like this person Firefox extension getSelection().toString() not getting the selected text
i read a lot other post and those code don't work in Firefox.
So i want to try another think. I have google search in context menu with already get selected text: IMAGE for Google Search
And i want to get that text from the google search context menu.
The extension is page-translator. I fixed the "auto language" and want to add text translation. I am working in this almost 3 weeks and this is my last try.
Here is the complete extension:
https://www42.zippyshare.com/v/AS5RAMVR/file.html

Related

How to get selected text in Office365 Word document from within a Chrome Extension?

I'm writing a small Chrome Extension that acts as a "web clipper". You can select a portion of text on a webpage, click the extension icon in the toolbar and the selected text plus the URL, selected document metadata, etc. is placed on the clipboard. (I'm writing this extension because I want the clipboard text formatted in a very specific way)
Things are straightforward when working with regular websites. However, both MS Word online and Google Docs present an interesting problem. Neither of them maintains the regular concept of selection, so window.getSelection() returns empty. (Google Docs is a topic of many questions here, so I'll leave it alone for now)
MS Word uses DOM elements, but maintains the selection by dynamically wrapping <span class="Selected"> elements around the selected chunks. I've tried fetching those with document.getElementsByClassName('Selected') but that only works in the javascript console - it returns an empty result when run by my Chrome Extension contents.js code.
So far, I've been unable to find any answers by googling, but I'm sure someone has solved this already...any tips appreciated.

Get dropdown menu in google extensions popup

I try create extension to google chrome - this extension must create button, that will show popup when pressed. That popup will contain input form, i think, and when i start inputting request string that will show dropdown menu with 'fast results' of search. So.. i can't find way to do it. I have one idea - i create and and connect them. With help of JS i add s of received data from google. But, this is do not work if packed as google extension (see proof: https://code.google.com/p/chromium/issues/detail?id=161302 ). Have you any idea?
P.S. Sorry me for two points: my bad english (not my native language) and, maybe, bad question - i just trying to start work with JS and google extensions. Thx for all.
You see in that bug that it is marked as fixed in June. This means it's fixed in whatever was the development version then. It will take some time until it reaches Stable.

Creating an Extension To Edit Google Doc Spreadsheet

I'm brand new to coding extensions for chrome so I'm hoping someone here can help or point me in the right direction.
I'm looking to create an extension that when you click on it a drop down comes up with 2 text inputs that will allow me to edit a google doc spreadsheet on the fly. Specifically, I'm tracking customer issues for my site and need to continuously add the number of times per day an issue arises.
So in the first text input box I would like to enter #issue click "Track" and it would add a +1 to the corresponding issue's cell within the Google Doc. In the second text input box if I enter #issue2 textdescription and click "create new issue and track" then the function would create a new row describing the issue (text description) and create a rule that from now on when #issue2 is entered in the first "Track" input box then a +1 will be added to that corresponding cell.
I have been able to create a popup box with inputs, however I am having trouble figuring out how to create a function to carry out what I would like to have done to the Google Doc Spreadsheet.
Hopefully, this isn't too wordy :/
Chrome extensions is not the way to go.
Look at google apps script. Use a menu, sidebar or both.

Chrome Extension: How can I show the find bar and supply text for it?

I am making an extension that stores the selected text from the currently active webpage into localstorage, then when the user click on this selected text in my extension's popup, the extension will fire chrome.tabs.create and open the website where the selected text was selected. These functions work, but I don't know how to trigger the 'find' function when the new tab opens. I want the newly created tab to highly the selected text that my extension stored. I think there are two ways to do this...
somehow trigger the 'find' function that the browser by default has. The one with 'Ctrl+F" or 'Command+F" triggers and insert the selected text in there
edit the HTML of the newly created page by highlighting the selected text.
new_source = { "url" : tab[0].url, "title" : tab[0].title, "quote" : selectedQuote, "id" : idSource};
sources.push(new_source);
localStorage["sources"] = JSON.stringify(sources);
This is how I'm storing my information
You can't trigger Chrome's native find dialog, but you can invoke window.find(). The main differences between the native dialog and find() are
find() only highlights one of the matches in the page, whereas the
native dialog highlights all. To be precise, find() will begin by
highlighting the match nearest to the top of the document, and
repeated invocations will move it down the page.
find() will highlight the selected text in with the default blue color, whereas Chrome's find dialog highlights its matches in orange. However, this can be mimicked by modifying the background CSS property of the ::selection pseudo-class.
Depending on your use case this might be sufficient.
However, if you want to highlight a specific quote on the page, and need to account for possible duplicates of that quote, then it's a bit more tricky, and I'm not sure it can be done perfectly. You'll want to get the precise location of the selected text using window.getSelection(), find a way to identify its startNode and endNode across page reloads (if they have ids, this is easy, but if not you'll have to resort to hacks), and then when the page is reopened, use Selection.addRange() to restore it.

Select items runs fine in Chrome et al but not on Android G-1 browser?

This little web page runs fine on my desktop but when selecting the area with a G-1 Android device (select box that says statewide..) the data refreshed with the requested data in the table but the text in the select box does not change,,, the other select boxes (month and year) work fine.. Fwiw the data is still rough and so is the gadget...
I've rebooted and restarted the g-1 to no avail..
http://dl.dropbox.com/u/4303088/gadgetdraftok.html
The broader question, i guess, here is how to debug a web page on any android browser? we don't have a firebug equivalent..
Further I confirmed the same bug in the Moto Cliq browser (also old still a 1.5) very strange every once in a while the G-1 operates correctly, but I can't figure out how to get it to do it, just that every once in a while the select shows in the window when selected and the data refreshes..
I have verified that this seems to be a verified bug in the early browsers... so now I'm trying to figure a work around, I added setFocus on the select box but it is ignored on the Android G-1
****New info****
I actually used this test tool from W3schools try-it site and it demonstrates the non-behavior in just a few lines..
http://www.w3schools.com/js/tryit.asp?filename=tryjs_focus i.e. it works fine on desktop but does not give focus when on phone.. anyone have a work around idea? ( I figured setFocus would be my silver bullet but sadly no)
I have three select boxes on the app so I need to display the selected info...as the selection is served.. not just initialization. FWIW the behavior seems to be on select boxes that have the selection dynamically loaded,, when I finish all three boxes will need dynamic loading now only the area box is dynamic, year/month are coded and so work.
What doesn't work properly are the items that contain spaces in them, e.g. Lee County.
Fixed the issue, A) spelled areas right in set a focus routine called at end of data refresh, (at one point I had it as area vs. areas) this forces the select to update the value and I went ahead and used the value of the select in the table head to provide "back-up visual confirmation that the area is elected.. works fine now ! :-)
http://dl.dropbox.com/u/4303088/gadgetdraftok3.html
So the main deal seems to be if you want to show the value, set the focus... I think, even though that is not required on the desktop.

Categories

Resources