How is it possible to execute JavaScript code on a specific page through a Firefox addon. I know I can use Greasemonkey but since I'm porting one of my Chrome extension, I want it to have the exact same features. So my question is, is it possible to execute JavaScript through a Firefox addon as if that JavaScript was executed in the page itself.
I was able to work it out somehow but every time I open a new tab, it gets executed in that tab again. Someone please help me fix this problem. I also want to use jQuery with this.
I use firebug, and go through the console to manually execute JS functions for testing. Alternatively, if you have to insert a whole JS include file, check out Fiddler.
Related
I'm trying to automate some online work through JavaScript and the Firefox (or Chrome) dev console. The work is mostly inputting the same (or similar) data on the same exact pages for many many people.
Example:
unique id
date 1 and 2
some more numbers
I wrote a very simple script that runs in the console and enters the data just fine.
The Problem
My script stops execution whenever it requires the page to reload or it loads another page. I cannot find any information on how to continue executing a script after a page has loaded.
My Limitations
I'm basically limited to what's on FireFox, Chrome, or Edge. Unfortunately, I cannot download any programs or tools that would make the automation any easier right now. Otherwise, I would just use Selenium and Python.
What I've Tried
First I tried to use the script that I describe above (simple DOM manipulation)
Then I tried to use the Selenium browser add-on, but I had to enter a starting URL for it to run. Selenium was not able to get past the login page of our system which is the only static URL that I can use as a starting point.
I then tried to use the Firefox Browser Console (different from the dev console) because the documentation seemed to suggest that I can use JavaScript on the entire browser (not just one tab). Unfortunately, I cannot find any helpful information on how to use the browser console for DOM manipulation. Everything that I search for points to how you create a browser extension, add-on, or how to use JavaScript on your own website.
What I Want To Do
I want to create a script that runs in a dev console. The script should take all of the data either from a separate page or an array then enter the data on each page for each person. I'll also have it prompt the user to verify the data before submission.
What I'm Looking For
What I'm hoping to get from this question is at least one three things.
An answer to the question's title.
Being directed to documentation or some other solution that can solve any of the above problems.
Being told if this is impossible and why by those who have more experience than me (I don't understand if the problem is just a lack of knowledge or limitations on the tools themselves.)
I think you can create a chrome extension and put your code in the background service worker. or use workers read this link
I have created some javascript code which searches the DOM and exposes some information for myself in the console, but in order this to work every time I have to go to Sources part of the console, go to the snippets part, click on the snippet name and run it.
Is there a way to make it autorun? Thanks!
idk, been using "Custom JavaScript for websites" chrome extension:
https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija
nov 2019 : These are current Chrome Extensions that can run scripts on any page you want
Custom JavaScript for Websites 2 regular updates, very easy to use
TamperMonkey regular updates and Canary versions, loads of options thus less easy UX
From what I understand, currently, this is not possible. If you want to auto-run javascript on websites I recommend using something like Tampermonkey chrome extension. It allows you to inject your client's webpage with javascript that automatically runs.
I use Chrome feature "Event Listener Breakpoint > Script > Script First Statement" that places breakpoint before first line of each script.
I check it on ten reload the page and before first script execution the Chrome pauses. I run all the snippets and code I need then I remove the breakpoint and resume the page load.
I try to debug my JavaScript but the issue is more about VS2012. When I run the website debugger it creates some dynamic pieces of code which you can study while debugging but all the JavaScript code doesn't update once I run the debugger. In short it runs the same JavaScript code as the first time I saved the respective document containing the current code. It seems to me like a pretty huge bug, and therefore it also encouraged me to investigate it through the internet but I seem to be the only one to experience it.
I think that's because you're trying to change the dynamic scripts. It doesn't work...
Instead of that, you should edit your source files and save them. If you do so, you don't need to stop the debugging process and start it again.
Just do edits in the source files and save them, then refresh your running page in browser and it works...
I need to execute JS code after loading all/specified pages in browser (i.e. predefined code). Which browsers and their plugins/component provide to implement it?
Manual way is open console (e.g. firebug) and execute. I want to do it automatically.
Not completely automated, but a Bookmarklet will let you run your JavaScript by clicking an item in your bookmark bar.
For complete automation locally in your browser (asuming Firefox since you mention Firebug) you should look for addons which solves your particular need. Grease Monkey for example is very useful.
I tried to use Firebug Lite (via the bookmarklet and also adding it to one of my web sites).
I seem to get the alert:
Unable to detect the following script "firebug-lite.js" ... if the
script has been renamed then please set the value of
firebug.env.liteFilename to reflect this change
Alot. Especially when I try to close the tab. This happens in Firefox, Camino and Safari.
What I'm wondering is, is this ready for use?, or do I need to copy the code, post it locally and hack it? I already checked the documentation, and it was pretty limited.
I was also looking at the mod dates and the site appears to have been relatively idle since mid-2008.
The javascript file rounds out at 77,305 bytes, so I would think you would not want to use it on a production site unless you were using a dynamic language and could output the script conditionally when you need to do debugging.
(i.e. http://www.somefakesite.com/page?debug=true)
As long as you're only including the file in the page when you are actually debugging, it probably doesn't matter where you pull the script from unless it doesn't work correctly, in which case you would have to modify and serve it yourself.