Add data from clipboard to out-of-page inputs via firefox addon - javascript

I develop an addon for Firefox and have the next question: is there a way to paste data from clipboard to borwser elements like a search or url field using Firefox addon api? And what is the best way to solve such kind of problem?

Yes get the data on the clipboard with: paste data from clipboard using document.execCommand("paste"); within firefox extension
Then do Services.wm.getMostRecentWindow('navigator:browser').gURLBar.value = varHoldingPasteData;

Related

How to remove stored values in firefox extension?

I have stored a colour value in my firefox extension using this code
function saveOptions(e) {
browser.storage.sync.set({
colour: document.querySelector("#colour").value
});
e.preventDefault();
}
This works fine but to retest the extension I want to completely remove all the data previously set by the extension and then wants to freshly test the extension.How can we remove stored values in firefox extension?
EDIT:
I am following this project and delete All using inspect>Storage>Extension Storage does not work.
In Firefox you can put in about:debugging in the URL which will bring up the list of addons you have installed. If you inspect the addon you'll see an option to view the Extension Storage. You can "delete all" from there.
Try using browser.storage.sync.clear()

Fill data into Office 365 Excel Form with JavaScript (Chrome Extension)

I'm new in JavaScript and wish to create something that can help my company to do some automated work.
I am creating a chrome extension to trace time in motion of my colleagues dairy work on the browser.
Basically the chrome extension will capture userName and click event and submitting to Office 365 Excel form by using URL Query String window.open(URL&userName) and setAttributes("Value", userName) then getElementbyId("button").click() to submit the form, but it unable to pass thru as the value will be reset and error will show "the answer is required"
Anything I missed out?
document.getElementsByClassName("office-form-question-textbox office-form-textfield-input form-control border-no-radius")[0].setAttribute("value","CCC")
document.getElementsByClassName("button-content")[7].click()
these are 2 line code i ran in javascript.
ExcelFrom Image
I found solution for Google Form to silent submission.and i wish to make it work with Office 365 Excel Form.
Thanks.

Autoincrement verification sms code (otp || 2fa) in browser

Is it possible to getting verification sms code from browser(javascript) application ( autoincrement || auto filling)?
There are article that on ios 12 safari appeared the function auto filling sms verification code (2fa). But i can't find description(html5 or javascript) how does this work?
UPD
it's work well in safari:
<input type="tel" id="single-factor-code-text-field" autocomplete="one-time-code">
I was find apple documentation for this feature
https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_an_html_input_element
I did not try it yet. But i thing it works only with secret key from clipboard. When you you tap to sms with code, ios suggest you copy code to clipboard.
It seems that the iOS autofill for 2FA is a bit of a mystery. Apple haven't documented a particular way to ensure this works. I had a search around to try to see if there was a specific HTML attribute you could use to ensure the device tries to fill in with the code, but I couldn't find anything.
As far as I can tell, Safari runs some heuristics on your page and on incoming SMS messages and if a code is found in the SMS and the page appears to have an input for a code then it offers the autofill. If you are looking to ensure this works on your site, I recommend inspecting the HTML of another site that you have seen it work on and use similar names for the input field.

View JSON file in Browser

It is not a programming question, but need your views in few words.
When we hit the JSON url in Broswer, it asks us to save the file.
Why this happens ?
Is there any way to view it on the page itself ?
Is there any addon available to view JSON file in browser?
In Chrome use JSONView
or Firefox use JSONView
If you don't want to install extensions, you can simply prepend the URL with view-source:, e.g. view-source:http://content.dimestore.com/prod/survey_data/4535/4535.json. This usually works in Firefox and Chrome (will still offer to download the file however if Content-Disposition: attachment header is present).
In Chrome, use JSONView to view formatted JSON.
To view "local" *.json files:
- after install You must open the Extensions option from Window menu.
- Check box next to "Allow Access to File URLs"
- note that save is automatic (i.e. no explicit save necessary)
Re-open the *.json file and it should be formatted.
Firefox 44 includes a built-in JSON viewer (no add-ons required). The feature is turned off by default, so turn on devtools.jsonview.enabled:
How can you disable the new JSON Viewer/Reader in Firefox Developer Edition?
json-ie.reg. for IE
try this url
http://www.jsonviewer.com/
Well I was searching view json file in WebBrowser in my Desktop app, when I try in IE still same problem IE was also prompt to download the file.
Luckily after too much search I find the solution for it.
You need to :
Open Notepad and paste the following:
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
Save document as Json.reg and then right click on file and run as administrator.
After this You can view json file in IE and you Desktop WebBrowser enjoy :)
For Firefox's Bookmarks JSON files, use this excellent Bookmarklet:
javascript:(function(){var E=document.getElementsByTagName('PRE')[0],T=E.innerHTML,i=0,r1,r2;t=new Array();while(/("uri":"([^"]*)")/g.exec(T)){r1=RegExp.$1;r2=RegExp.$2;if(/^https?:/.exec(r2)){t[i++]='['+(i)+']:<a href='+r2+'>'+r2+'<\/a>';}}with(window.open().document){for(i=0;t[i];i++)write(t[i]+'<br>');close();}})();
Source: "alterna" from forums.Mozillazine.org:
http://forums.mozillazine.org/viewtopic.php?p=5551705#p5551705
I have the Content-Type of my JSON-printing CGIs set to text/javascript.
Works fine for both displaying in browser (e.g. Firefox) and processing in script.
Of course there's no syntax-highlighting in this case.
If there is a Content-Disposition: attachment reponse header, Firefox will ask you to save the file, even if you have JSONView installed to format JSON.
To bypass this problem, I removed the header ("Content-Disposition" : null) with moz-rewrite Firefox addon that allows you to modify request and response headers https://addons.mozilla.org/en-US/firefox/addon/moz-rewrite-js/
An example of JSON file served with this header is the Twitter API (it looks like they added it recently). If you want to try this JSON file, I have a script to access Twitter API in browser: https://gist.github.com/baptx/ffb268758cd4731784e3
I would also recommend to use Notepad++ with json-view extension. You get the extension here: https://sourceforge.net/projects/nppjsonviewer/
Install and restart Notepad++.
Then open json-file in Notepad and go to "extensions -> Json-Viewer - > Format JSON. Then you habe the hierarchical view of json.
You can also use one of the online-viewers (http://jsonviewer.stack.hu/ , https://jsoneditoronline.org/) which look nice, but I wouldn't recommend this if your data are sensitive in terms of privacy.
For Safari 12 and later, you can try the JSONBeautifier bookmarklet. Also works with other browsers.
I created this because JSON Formatter for Safari stopped working in Safari 12. There are a few new options for Safari 12, but I didn't find an open source one in the App Store, and I do not trust closed source browser extensions.
This can be used as a bookmarklet or the source, json-beautifier.js, can be copied and pasted into the browser console. The code is freely available for review and is less than 100 lines of code including comments. Runs entirely on your device and never sends your data over a network.
Works with local files too. 🤓
Try this one Chrome extension https://chrome.google.com/webstore/detail/json-%3E-table/pjdecdkdljmchigbkalnblidepkeojda
Just install and open URL in browser
Microsoft Edge Browser
Json format easily view this but you have some changes in browser.
Browser setting
Go to browser edge://flags/
Search Json viewer
Change "Default to Enabled"
Restart Browser
[Done changes]
Chrome Browser
Install Extension Json viewer
Then view this pure json and change setting also
Right click on JSON file, select open, navigate to program you want open with(notepad). Consecutive opens automatically use notepad.

how to retrieve RTF content from ClipBoard using javascript/JQuery methods

I want to retrieve the RTF content from the Clipboard(Orginating from MSWord).
Is it possible to retrieve it using javascript / JQuery methods?
In general, no. You can only get it if the user triggers a paste. WebKit provides a means to access the clipboard during a paste event and IE provides a clipboardData object that sometimes allows this (depending on the security settings) but that's it.
You can use a hack to effectively redirect a user paste into an off-screen element. See my answer here: JavaScript get clipboard data on paste event (Cross browser)

Categories