Not able to register preferences on mozilla using registerFactoryLocation - javascript

I m XPCOM component for registering the preferences on mozilla firefox but it is not getting reflected in prefs.js file.
Anything more i need to use apart from registerFactoryLocation code....
Thanks in advance :)
ya sure,I have developed an XPI,in that in comonents folder I have added a mymanager.js file. In that I have creted a component using the code like.......... http://kb.mozillazine.org/Implementing_XPCOM_components_in_JavaScript but this code does not able to add the _prority preferece to mozilla firefox preferences(prefs.js) file. I need to do anything more to register the preference...

Although your extension can register preferences, prefs.js only contains changed preferences, so they won't automatically appear there.

Related

Woocommerce-admin extension: changes to js/index.js have no effect

I am trying to write an extension for woocommerce-admin analytics. I have installed an example extension and it runs fine. But any changes I make to its js/index.js are not reflected in the browser.
Details:
I installed woocommerce-admin as described here:
https://github.com/woocommerce/woocommerce-admin
I then installed the add-report extension as described here:
https://github.com/woocommerce/woocommerce-admin/tree/main/docs/examples/extensions
The example extension works fine when I look at http://localhost/wp-admin
The Woocommerce Dev Docs say "You can make changes to Javascript and PHP files in the example and see changes reflected upon refresh", but when I modify add-report/js/index.js nothing changes in the browser.
What am I doing wrong?
I have found my answer: I should have been editing the js file in the main woocommerce-admin/ folder, not the js file in the new add-report/ plugin folder.
Changes to /wp-content/plugins/add-report/src/index.js are ignored, and have no effect in the browser :-(
Changes to /wp-content/plugins/woocommerce-admin/docs/examples/extensions/add-report/src/index.js are built successfully, and have an effect in the browser :-)

python : disable download popup when using firefox with selenium

I have script that using selenium and firefox to automating download action.
The problem is whenever I run script I always get pop up from firefox keep asking what kinds of action I would like to do, even though I set download path in firefox preference. I checked files and folders to create master mimeTypes.rdf for all users, but I couldn't find mine.(I'm using ubuntu). I found ~/.mozilla/firefox but there was no file for directory of my profile name nor any file has an extension like .rdf
here is the criminal's pic that making me crazy
firefox download popup
below is what I've done to disable the popup.
profile = FirefoxProfile()
profile.set_preference("browser.download.panel.shown", False)
profile.set_preference("browser.helperApps.neverAsk.openFile", 'application/zip')
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", 'application/zip')
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", "/home/i-06/Downloads")
driver = webdriver.Firefox(firefox_profile=profile)
I have spent many hours trying to suppress that "save or open" pop-up that appears when downloading a file using the firefox driver with selenium (python 3.x). None of the many suggestions involving various values for profile.set_preference worked for me. Maybe I missed something.
Still, I finally got it working by the other method that is recommended : using an existing firefox profile.
You can tweak your default (or custom) profile to the file save behaviour you want. Type the following in the firefox address bar and make changes here :
about:preferences#applications
Then the only setting up you need to do to download the file into your current working directory is :
from selenium import webdriver
fp = webdriver.FirefoxProfile(<your firefox profile directory>)
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.dir", os.getcwd())
driver = webdriver.Firefox(firefox_profile=fp)
If you have a typical ubuntu setup, you can find your default firefox profile dir by viewing ~/.mozilla/firefox/profile.ini
In that .ini file, look for Path under [Profile0]
I doubt you need to define both. Remove the below line from your code
profile.set_preference("browser.helperApps.neverAsk.openFile", 'application/zip')
Also sometime the MIME type of zip file can be different based on the server. It could be any of below
application/octet-stream
multipart/x-zip
application/zip
application/zip-compressed
application/x-zip-compressed
So in Network tab check what is the content type you are getting and add that to your profile to make sure the dialog doesn't come
I removed profile.set_preference("browser.helperApps.neverAsk.openFile", 'application/zip') as Tarun Lalwani suggest and it still work. But my problem was that I put application/mp4 instead of video/mp4. You could check MIME type here.

Vaadin #Javascript : clear cache for updated JS file

I have a #JavaScript annotation in my application to load a .js file from the classpath.
Now I've made an update to the file and redeployed (locally), but I always get the old version back. I've tried reloading everything (ctrl+R, ctrl+F5) but that doesn't work and also I wouldn't want the users to have to do that.
A trick I used in the past (without Vaadin) was to append a request parameter with the version (e.g. ?version=1) and update that so that the URL changes. But apparently that isn't allowed for the #JavaScript annotation (Vaadin doesn't even try to load the file).
I have overcome this by utilizing the resourceCacheTime parameter of the Vaadin servlet configuration:
#VaadinServletConfiguration(ui = MyUI.class, resourceCacheTime = 0)
Although it has its limitation as described in my answer to another question here.
This is browser feature to localy cache JS files, nothing to do with Vaadin.
As you figure it out yourself: If you want to make sure users have latest version of JS file, you should rename JS file name to: script_buildNumber.js.
Use the Chrome's incognito feature (and not use it when visiting spicy/unpleasant websites).
Just open your browser in Incognito mode https://support.google.com/chrome/answer/95464?hl=en and the browser will cache nothing.
Other browsers have this feature as well (Opera, IE, Firefox, Safari).
As I noted in my comment on the question on January 12th, renaming the file worked. This seems to be currently the only way, although it's far from ideal.

set about:config parameter of Firefox

I am using Mozilla Firefox 5.0.
I want change value of "signed.applets.codebase_principal_support" parameter of about:config using JavaScript code.
Is it possible?
No that is not possible. If you can access to the harddrive you may change the prefs.js file.
The file is normally located in windows under %appdata%\Mozilla\Firefox\Profiles\<randompart>.default\prefs.js. There you can add or modify such a line:
user_pref("signed.applets.codebase_principal_support", <<your value>>);
I cannot comment yet, so i wrote this in an answer.
Please do NOT change prefs.js, as the beginning of the file and the official website tell. You can either change user.js, which will override all settings made in about:config on startup of firefox, or use the API (i dont know much about it, look it up yourself) or simulate the access of about:config in the browser.

View js files in firefox

Everytime I try to navigate to a JS file on Firefox I get a save-as dialog. I would like to just be able to view the source in the actual browser and not have to download and open the file in another editor.
Is there any way I can force Firefox to view the files?
EDIT here's a snapshot:
In Firefox, You can use the view-source: psuedo protocol.
Enter into the URL address bar:
view-source:http://server/whatever/your/url/is.js
See also:
How can I convince IE to simply display application/json rather than offer to download it?
I would try the excellent Open in Browser add-on, which is worth having as part of your standard Firefox install.
Have you ever been annoyed when you wanted to see a document and the download popup appears which forces you to select an external application to view it?
This extension allows you to open the document directly in browser. You can also change the MIME type of a document being viewed.
This extension is necessary due to a 9 year old bug in Firefox. When given Content-disposition: attachment by the server, Firefox will only offer to open the resource with an external application or to save it to disk. "Open here, now, in this Firefox" should also be an option for MIME-Types it handles, but currently isn't.
I agree with the last comment, from just 8 days ago:
not allowing content types that Firefox can handle (text/plain, image/png,
etc) is to be viewed directly is a clear-out bug. Dancing through hoops like
saving the file to some random place then opening it manually is a ridiculous
workaround.
There are three places that Firefox looks for the MIME type of a .js file. (There is a fourth place for some files, such as .html files.)
The first is in a file in your profile called mimeTypes.rdf; if you have ever clicked on a link to a .js file with an unrecognised MIME type then when you save it Firefox will associate that MIME type with .js files. See Mozilla bug 332690 which describes the equivalent bug for .svg files.
The second possibility is that your registry entry HKEY_CLASSES_ROOT\.js\Content Type may have been set to an incompatible value. If present it should be set to one of the values application/x-javascript, application/javascript or text/javascript.
Only if these locations are not set then Firefox will use its internal default which I believe is application/x-javascript.
There is a nice JSView extension that should help you: https://addons.mozilla.org/en-US/firefox/addon/jsview/
If you view the source of a website in Firefox, you can navigate into the javascript files from there also by just clicking on the link in the src="" property.
(This could potentially be influenced by Firebug that I have installed)
Using the devtools it looks like this Ctrl+Shift+K > Debugger > Sources:

Categories

Resources