I've got some custom JS that i'm looking to deploy on a live site, but I want to test it out first.
I'm a third-party consultant to the target site managers, and am not part of their build process, so I can't deploy in their test environments. Since it's a DOM traversal library, it's pretty specific.
I was wondering if anyone knew how to get my local javascript files to auto-insert for a particular domain or host.
Thanks!
Or you can try CTRL + SHIFT + I which will open the tools in Chrome and Firefox. Within your browser's developer tools there is a tab called the Console. You can use this to run small snippets of JavaScript code.
To execute JavaScript in a browser you have two options — either put it inside a script element anywhere inside an HTML document, or put it inside an external JavaScript file (with a . js extension) and then reference that file inside the HTML document using an empty script element with a src attribute.
You can also press Ctrl + Shift + C on your keyboard to open the developer tools. In the top-left section of the developer tools, make sure Elements (A) is selected at the top. In the condensed code under the Elements header, find the <script> tag containing a link to a . js file (B).
Why not just inject the script you're working on in firebug's console:
var script = document.createElement('script');
script.src = 'url to local file';
document.appendChild(script);
Or if you have jQuery
$.getScript('url to script file.js');
Install Greasemonkey Add-On for Firefox.
This Add-On can inject Javascript for pages with certain URLs matching a regex given in the injected JS-file.
If you want to learn how others are writing their Greasemonkey-Scripts then search for FF Add-Ons that start with "BetterXYZ" like BetterGmail, BetterFacebook, BetterGoogle ... Greasemonkey-Skripts are in fact Javascript-Files with special initial JS-Comment and a special file extension "*.user.js".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With