Making the browser reload user script automatically - firefox

I'm currently working on developing a user script for Firefox. Every time I've made a change, I have to manually refresh the tab with the script and reinstall the script. I want to do the thing that's asked in this question, but in Firefox.
Is there a way to automate this so that the user script automatically gets reinstalled every time I save the file in emacs?

If I understand your quesiton correctly you want to avoid the hassle of reinstalling your userscript each time you save it in your editor.
Here are the step-by-step instructions.
Install Greasemonkey in Firefox.
Install your script in Firefox (via Greasemonkey).
Firefox Menu -> Tools -> Greasemonkey -> Manage User Scripts -> Right-click on the script you are working on.
(a) Select "Edit" to open your script in your default editor (emacs?).
or
(b) Select "Show Containing Folder" to open the folder containing your script and subsequently open it with a custom editor (e.g. emacs).
Update the script in your editor as needed and the modification will take effect the moment you save it. Yet you still have to refresh the web page on which your script runs in order to see the result.

Related

Disable cmd-R for executing scripts in Google Apps Script Editor on Mac

I've just started to use the Google Apps Scripts Editor on Chrome on a Mac. The good people at Google added a shortcut for quickly running scripts, which on Windows is ctrl-R, and probably doesn't conflict with anything. Then they translated it to cmd-R on Mac, which globally makes sense. As a Mac user however, I'm used to using cmd-R to reload pages (as compared to F5 on Windows). The google shortcut takes precedence, meaning that each time I hit cmd-R to simply force updating the page (because it sometimes help to reload the page), it launches the script I'm viewing. I'm worried it may at some point execute a script that I'm not intending to execute at that particular time.
Is there any way to disable the google shortcut? I'm perfectly fine having to go and click the arrow, but I'm not fine risking launching a script when I don't mean to.
Unfortunately, there is no way to disable the shortcut keys in Google Apps Script. However, you can add a confirmation dialog box in your script to add extra layer of protection from running your script accidentally.
Example:
Code:
function myFunction() {
var confirm = Browser.msgBox('Are you sure you want to execute the script?', Browser.Buttons.OK_CANCEL);
if(confirm == 'ok'){
//insert your code here
}
}
Dialog Box:
Reference:
msgBox(prompt, buttons
Following #Nikko's suggestion I'm displaying a dialog box when the script is started (i.e. top-level), and when the answer is "cancel" I simply wait (Utilities.sleep()) for 5 minutes, and then again. This prevents the function from being executed until the script would be killed automatically, but more adequately it keeps the script execution dialog box displayed, in which you can choose to cancel the execution. So you don't have to wait 5 minutes, just click "cancel" while the script is doing nothing. Again, dirty, but works for me.
if(Browser.msgBox("Are you sure you want to run this script?", Browser.Buttons.OK_CANCEL) == 'cancel') {
Utilities.sleep(300000)
Utilities.sleep(300000) // just to prevent accidental execution in the last split-second
}

VBscript SAP loose focus by Task Scheduler

I've got a problem i can't pass by. I have a script that is generating table in SAP and exporting is as spreadsheet and saving in proper location. It works perfectly when I do it by double-clicking on file, but it can't finish script via Task Scheduler in the moment it's exporting file from SAP in 'Save As' window. Script opens 'Save As' window on exporting and just SendVkey Tab Tab Tab Tab Tab, paste proper file location, Tab and Enter.
I figured out it works when i run it through Task Scheduler and simply click on SAP while script is running so it gets focus and everything is ok. And if I just run it by Task Scheduler and don't do anything it seems like it's working in background and SAP doesn't have any focus so my TAB keys are going somewhere else on windows (probably desktop) instead of going in 'Save As' window properly. The same story is when i Run file by double-clicking and minimize folder where the script is. It looks like SAP looses focus again and my TAB keys are not working.
So script is only working when i double-click it and don't do anything or when i run it by Task Scheduler and click on SAP window to give it focus. Is there any way to bypass it? Can i somehow simulate click on SAP window when script is running automatically or do i have to change something? I tried many ways, but i'm a beginner and can't figure it out.

Is it possible to run a automatic post clone script in cloud 9 ide

I would like to automate a quick start of SQL-MVC.
Can I set a script to run automatically after a git repo is cloned? like this:
auto-run.sh
Also, is it possible to launch a browser window to automatically open to the applications URL at the end of the script?
I have checked all the docs, but I don't find anything on the subject.
From the Git book src:
It’s important to note that client-side hooks are not copied when you clone a repository. If your intent with these scripts is to enforce a policy, you’ll probably want to do that on the server side; see the example in “An Example Git-Enforced Policy”.
So, the automatic running of a script on clone is not going to work. However, you can commit the auto-run.sh file within your repository and ask the user to run that after cloning.
You can open a new browser window on your local machine by adding the correct command within the shell script, (for example, on a mac I usually just use open). However, since Cloud9 workspace doesn't have a window manager, you won't be able to do that from the Cloud9 Terminal. One way to open a browser pane within Cloud9 IDE (not in another tab, I don't think that's possible) is to echo the url, and ask the user to click on it at the end of the script, so something like this:
Please click https://www.google.com to continue
and the Cloud9 terminal is smart enough to open the url in a new browser pane within the IDE when the user clicks on the url.

Opening up iTerm / Terminal with commands by default.

My current use of iTerm is the following everytime:
- Open up
- cd into my project folder
- open up another tab
- cd into my project folder
- Grunt Watch
- open up another tab
- SSH into live server
This is getting a bit tedious now, is there a simple way to make a one click for all of this to be done? I remember back in the windows days you could create custom command prompt files so it would open up and you could just double click it like an app.
Is there anyway I can do this? I have looked at the profiles and I don't think I can do what I am after with that.
Just need pointing in the right direction.
If you're using iTerm2, there is a feature called Arrangements (see the last entry on the page). With this, you can set iTerm to open a series of profiles (which can be set to run a command at startup, start in a specific directory, run a certain shell, etc.).
It seems that creating one profile for working in a directory, a second for the Grunt Watch, and a third to SSH should be trivial, and once the arrangement is saved, it can be recalled with the press of a hotkey (Cmd⇧R on my install). You can also set this to save split-pane windows if you don't want a separate window for each of these tasks.

Run command on client side from browser

For our intraNET we need to run application, when user clicks on link. Security is done another way (apache, firewall). This is only for users in our company. Operation system is WindowsXP+ (some Linux).
I tried link to script file (http://intranet.domain.com/run.bat):
Chrome
can't change mimetype
browser downloads it, and after doubleclick and warning it works with .bat
Opera
with mimetypes tunning, it works with .lnk file, immediatly after click
Firefox
with mimetypes tunning, it works with .lnk file, immediatly after click
Explorer
.bat file works after warning and click on 'Run'
Safari
.bat file works after warning and click on 'Run'
It works, but with warnings and clicking. Maybe there are some other solutions (i read here) using AIR2 plugin or NPAPI plugin, but i have no experiences.
I am looking for ready to use plugin written for this purpose (commercial too). Of course we can install any application/plugin on client computer. Plugin which i can render on webpage and configure to run some command with parameters on click event (command and parameters could change on every page load, can not be compiled in plugin).
I know, there are some questions on this topic, but.. i did not find good solution. Thank you for any help.
All those warnings are there for a reason! If you could run a batch file in this way without warning this would be a huge security risk.
The best way to get this to work would be to write a signed ActiveX control that users download to their PC, install (which would require that the user confirm that they wish to install the control) and then have the ActiveX control run the batch file. This would then allow the ActiveX control to run batch files without prompting the user, however is probably way more hassle than its worth for a one-off action.

Resources