I have developed a very powerful and complicated bookmarklet, but it's starting to bump into the edges of the bookmarklet format. I'm considering turning it into a browser extension. For Chrome, I found this tool that makes it easy to get started. I'll need to tweak the outputs a bit, but it's fairly simple.
I'm wondering if there's something similar for Firefox. I want an extension that adds a button to the browser, and when you click it, it runs a script on the page. Can anyone point me to a tutorial, or the related part of the documentation?
Bookmarklets are very simple. The WebExtension API is not good if you want to use the addon right away.
The SDK is guaranteed to work right now, and the level of features which you will use from the SDK for a bookmarklet will continue to work in the future.
It's quite easy. What you want to do is follow this guide: https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29
Do the prerequisites (install node [which installs npm]) should take just a few minutes.
Then when you get to the Implementing the add-on section of that guide. Don't paste what they say, instead paste this:
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*.mozilla.org",
contentScriptFile: [data.url("jquery.js"),
data.url("my-script.js")]
});
Modify the include to match the website you want to target.
Then create a folder next to your index.js file, call it data. Inside, create my-script.js and paste your bookmarklet. If you need jquery then add that in there as well. If you don't, then remove jquery from the contentScriptFile line in the snippet i pasted above.
Then type in npm jpm xpi in command line (as thats how you use jpm).
To test - Make sure to go about:config and set xpinstall.signatures.required to false, as signing is required for Firefox now. Then drag that xpi to your Firefox.
Then when ready, upload that XPI to addons.mozilla.org :)
Starting at version 42 (current stable version), Firefox includes support for WebExtensions, ie the same API as Chrome Extensions, so you can luckily use the same tool.
Take into account that it's work in progress and it's not 100% ported, so please read the docs about the state of it.
The current Addon SDK will be deprecated in the future in favor of WebExtensions, so I think you should give WebExtensions a try, even more when it allows you to only have to maintain one code base.
Related
I have designed a website using Firefox and am now looking to integrate a softphone into the webpage, but unfortunately it is made with ActiveX, so Firefox won't support it.
I have tried opening my page in IE9, and it looks a mess because I've used CSS3 for a lot of it and haven't coded it for different browsers because we will only be using Firefox within the office.
Is there a way that I can tell my page in Firefox to specifically open a new page in Internet Explorer and just have the softphone in there? Or is there a way to get ActiveX running in Firefox with a plugin or something?
You can open a link in Microsoft Edge from any browser by adding microsoft-edge: in front of the url in the HREF.
EDGE (works)
I don't know how to get it to work in other browsers though. My team and I spent quite a bit of time on it and couldn't find a raw HTML/JavaScript solution.
I don't think you can open a IE window from firefox, but you can easily build a firefox plugin based on your activex using http://code.google.com/p/ff-activex-host/
It really depends on your exact situation.
If you are targeting multiple users outside a corporate network this is hardly possible to achieve. However, if you are targeting your company's network it's possible to do this using custom protocol.
Your link then would look like: ie://opens_in_ie.com
You'll have to make changes to registry of target computers though. More info about custom protocols is available here: http://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx
In most cases, system administrator can do this remotely.
IETab V2 will let you open a tab within Firefox that runs the IE engine.
Once installed, you can force a link to open with IE by formatting the URL or bookmark like this:
chrome://ietab2/content/reloaded.html?url=http://domain.com
It's somewhat specific, but I created an internal site at work, and I wanted to link to another internal site that only works in IE. To do this, I created/defined my own application protocol in the registry. Then I added to my links the protocol header. This is similar to what apple does when you click a link and it opens iTunes. The downside to this approach, however, is that users will have to install the registry modification for it to work... like I said, it's really a solution for a very specific scenario.
Same answer as from chuck wallace
If you want to start from for example in Internet Explorer, go to C:\Program Files\Internet Explorer\iexplore.exe and create a shortcut to the Desktop.
When you check the properties from this created shortcut, you will see the Target: C:\Program Files\Internet Explorer\iexplore.exe.
Now you can place the shortcut from the website, behind the Target. It will show something like this: C:\Program Files\Internet Explorer\iexplore.exe www.nu.nl. Or this C:\Program Files\Internet Explorer\iexplore.exe https://stackoverflow.com.
This way it opens IE first and then the website.
I need to find a way to install a Google Chrome plugin onto Chrome automatically. It would be preferable if you gave advice pertaining to .bat and .vbs files as that is where my "specialties" lie.
When I say automatically, I mean you would double-click the script and it would put the plugin onto the browser.
C:\Documents and Settings*UserName*\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions
Is where the extension data is. I'm working with Windows machines, by the way.
EDIT: Sorry, the vibe I was intending to give off was "advice" not "gimme free code".
Where to start..
There are some limitations you will have to deal with, due to security measures taken.
Your extension must be published in the Chrome Web Store.
Your extension will start disabled in Chrome with a prompt to enable it.
If you can live with that, the procedure is outlined here. Don't ask me for sample code, but it should be pretty straightforward.
In short, all you need is to create a registry key based on the extension ID. Chrome will pick that key and add an extension - but will ask the user to confirm.
I use the Addon SDK to display a Panel. It's working fine, but I would like to set the noautohide property to true, so the panel will not closed automatically when user clicks outside the panel.
I managed to access to the panel object using "chrome" authority but I am afraid of the red mark "experimental" ;-)
So I would like to edit panel/utils to expose the noautohide property. Is it possible to "override" or "embed" my edited file in the extension package?
Unfortunately, there is no supported way of doing this (that I know). Searching the SDK sources for noautohide without any results seems to confirm this.
Personally, I'd use the require("chrome")-and-get-the-XUL-element workaround for now (but keep in mind that there could be more than a single browser window), or just not implement it at all.
I would advice against patching the SDK and/or "embedding" a patched panel library.
The former would require to use a bundled SDK instead of the built-in SDK and seeing all the changes that go into each Firefox release, you'd likely have to re-package your XPI with every major Firefox update. Also you're not allowed to host add-on on AMO that bundle a patched SDK.
The latter option of "embedding" just the panel lib has the same maintenance problems. Also, it isn't exactly easy to extract/clone the just the panel library from the SDK... At the very least you'd have to clone sdk/panel.js and sdk/panel/*.js maybe even more.
It might be helpful if you filed a feature request.
Rather than patch it what you can do is as addEventListener for popuphiding and do event.stopPropagation(); and event.preventDefault();. Then just add a close button that on click removes that listener and then hides the panel. I couldn't get arouund the noauthohide any other way:
Avoid panel to autoHide in Firefox extension
I am struggling with breakPoint issue in VS 2012 for more than hours. I am from eclipse background, there I never heard about such issues.
Problem :
The breakpoint will not currently be hit. No symbols have been loaded
for this document.
I have placed the break point in click action of Jquery.
I found the issue using the IE script debugging., The file loaded was old file., i.e I have modified a lot, but I can see no changes in the one which is loaded in IE. How to fix the bug
What I have Tried :
I know this question is duplicate, but being a newbie to VS and C#., I could not understand the older answers. For example, in this answer, he told to choose Debug -> Windows -> Modules. But I doesn't have Modules under windows in VS 2012. Also even though I read, I could not understand the explanation.
Also I am quite new to term Assemblies and PDB. Though, I located PDB files as he said. But how to open the .pdb file?
Need :
Could anyone explain me the same answer in easier term (with more explanation).
I found this out by accident with my VS2012 and ASP.NET MVC, maybe it can help somebody. I noticed that breakpoints in javascript that's inline in the *.cshtml file like this won't get hit (note that this file is a cshtml file):
But breakpoints in external *.js files will get hit:
Try to add debugger; key word before $.getJSON
Also make sure if you use IE to un-check the disable script debugging
Internet Options> Advanced tab> Under Browsing.
As I think this issue is related to Javascript debugging not C#
This results for me:
In your web application make sure Silverlight and ASP.NET debugger are enabled.
How to get there?
=> Right click on the Web Application => Properties => Web tab. Under Debuggers section make sure Silverlight and ASP.NET are enabled.
Running Visual Studio 2013 or Visual Studio 2015 RC, I've found that to get a breakpoint to work in a .js file I need two things to be true:
I need to start Visual Studio by right-clicking the VS shortcut and select "Run as administrator". (If right-clicking on the Taskbar icon, select the application shortcut icon from the pop-up menu and right-click on that to get a context menu that includes "Run as administrator".)
I need to set Internet Explorer as the default browser that will be opened for the web debugging session. If I choose Chrome or Firefox, the breakpoint doesn't work for me.
After opening and closing VS, rebooting the PC with all with no chance, this workaround worked for me in VS 2012 ( Ver 11.0.50727.1 RTMREL ):
In Project Property Pages, under Start Options, in Debugger section, only ASP.NET was enabled. As soon as I enabled Native Code and SQL Server, that red circle with plus sign inside, enabled again.
No idea why this worked! No active connection in Server Explorer nor using any native code in the project!
I had the same problem. You can use VS2017 to debug JS code this way.
When you set VS to launch the browser (Chrome in my case), it opens a new Chrome window. I was trying to debug the specific code (different URL from the window that opened) in a new tab. So I had the 'The breakpoint will not currently be hit. Breakpoint set but not yet bound' in VS.
I found out that if I opened the new URL in the original tab it suddenly worked. Seems that VS is tied to that particular tab.
Hope this helps.
These are the particulars of my situation: VS 2017 - Mainly C# code with some embedded HTML/JS which I needed to debug, Chrome (Version 68.0.3440), Windows 10
As this is Javascript code, so you need to use a javascript debugger. Generally internet browsers come with a debugger/inspector menu, which allows you to inspect/debug your javascript easily. Such debuggers come with a lot of useful features such as HTTP request/response inspection, browser session/local storage, etc.
Actually there is "Modules" option, but it's enabled only when you are in debug mode.
You can just press Ctrl+D,M combination when you're in debug.
In few words, PDB is a file that contains all debug information about your assebmly, you can not debug an assembly without this file. Assembly is a file that contains precompiled code for exetuion via CLR.
Could you provide a bit more information about your problem. What kind of application you are trying to debug for example?
Also, if you have located you pdb files made EXACTLY for your assembly, you can load it by right-clicking your assembly in modules window and selecting Load Symbols From > Symbol Path
Try deleting all breakpoints and restarting debugging in Visual Studio.
I would like to be able to add custom snippets of javascript to any site that matches a regex. This is mostly because of sites that I use daily because of specialized content, but which have a poor design. I want to be able to do something like:
Visit site See that sidebar overwrites content
Whip out developer tools, find div id for sidebar
Edit a snippet of javascript which is executed on document.ready for this domain:
$('#sidebar-right').remove();
A bit of searching for user scripts tells me that I need to be writing a Chrome extension, which seems unfortunate and overkill. Is there not an easier way, or an extension which is nothing but a javascript editor that assigns snippets to domains? I'd really like to be able to edit in Chrome itself, or at least have a file that I can just leave open in MacVim all the time. An extension requires unloading/installing to update as far as I can tell.
If I just had one big javascript file, that would be fine. I'd just wrap my customizations in domain checks.
Bonus love if I can write in CoffeeScript.
The answer is to use the Tampermonkey chrome extension.
https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo
Why not dotjs http://defunkt.io/dotjs/ ? It's local, you can version it with git, you can easily take it to another computer...
Another alternative that neatly solves the problem is Custom JavaScript for websites. You just need to install the extension, which takes around 2 seconds, and then you can immediately start typing your custom JavaScript for the specified website.
The extension automatically recognizes the current website, so all you need to do is write your code and click on Save. You can also easily import jQuery or your external scripts for convenience.
Custom JavaScript for Websites 2 is an alternative to Custom JavaScript for Websites, with some bug fixes and sync scripts across devices feature.
Snippets are available directly in Chrome Devtools
https://developers.google.com/web/tools/chrome-devtools/javascript/snippets
Witchcraft is another Google Chrome extension for loading custom Javascript and CSS, and it is supposedly for more avanced users. The older dotjs project repository lists Witchcraft as its successor.
What you're looking for is Greasemonkey. But wait, Greasemonkey is for Firefox only, right? Turns out, you can install Greasemonkey user-scripts as native Chrome add-ons. Just go to userscripts.org and hit the Install button on one of them, and Chrome will automatically convert it into a native add-on. Then, write your own and install it using Chrome.
Note: This only works in Chrome 4.0.