I'm working on internal project that generates an applescript based on a web form.
I can generate the correct script, but I'd like the option for somebody to click "run script" from the browser and have it do its thing, rather than copying and pasting the generated script into osx's script editor.
http://www.macosxautomation.com/applescript/linktrigger/
I've read through above but honestly it's not detailed enough for me to make useful sense of. Has anybody had luck with this?
You can create a link to Script Editor like this:
Link
In the example above the action parameter is set to create a new document and the script parameter defines the script copied to the new script document. After clicking the link a couple of confirmations are asked.
Apple uses this method in its Mac Automation Scripting Guide where you can test how it works.
Executing a script directly from a browser would be a massive security risk.
The method you linked would require that the script is already saved on user's computer as an application bundle.
Related
Is there a simple way to start programs on mac from html?
I made an html page with a text field and a number of buttons. The intention is that when a code (numbers) is entered, it is copied to the clipboard. Via the buttons (each of which must open an application) the desired app opens and paste the code into the application (search or something ...). I already made this in AppleScript, but the layout is not that nice. That is why I wanted to work with HTML / CSS. Is there a simple way to run programs on mac starting from html/ Javascript?
I'm not sure if this is what you're looking for, but on Macs you can define custom URL schemes that will launch script applications to handle data. See:
Launch Scripts from Webpage
Which is an AppleScript-specific discussion of this:
How To Create Your Own URL Scheme
I'm also not sure of what you are looking for exactly, however, if it is vanilla JS, you can open the HTML file in the browser, which will also let you use the JavaScript as long as it is imported properly.
To open the HTML file in the browser, you can go to the file in the Finder then right-click and select "Open with Chrome". If you prefer to use a different browser, you can open it with whatever browser you want.
We've been testing HTML widgets in iBooks 3 and had some success in connecting online. One of the drawbacks, though, is it requires user interaction to actually expand the widget and run Javascript. Is there a way to run Javascript in the background of the iBook, without requiring user interaction outside of regular paging?
For example, if we wanted to have Mixpanel running in the background, how would we do that? Is there another type of widget that allows this to happen? Or is there something else that runs javascript besides the HTML widget?
edit: To clarify, I'm using iBooks Author to create the full book, which has the functionality to add HTML widgets inside it.
I assume you are talking about a book authored using iBooks Author, which by the way would be a useful detail to put in your question. I don't know iBooks Author or its widget architecture or to what it extent it exposes the ability to place JS on a page.
However, in "normal" ebooks authored in (X)HTML/JS/CSS, there is no essential difference between JS in the reader and in a web browser.
I'm not sure what you mean by "running in the background"; JS runs when something tells it to, whether that something is it being placed on a page in a SCRIPT element, or put it in an onLoad or some other event handler.
Widgets in ibooks do not execute JS until they are activated by the user. So even though the link for the widget may be visible in your book, it's not capable of making connections via ajax or doing anything else until launched. Once launched, the widget has no access to the book content either. If you wanted to run mixpanel in a widget you could, but it wouldn't make sense unless your widget also contained all the content of the book (and a reading system).
Is there any way to "edit" a "server side" javascript file in one of the mentioned browsers that will save the js edits on the client side and replace the server side scripts?
Basically I want to edit the javascripts on the server. Obviously I can't save them on the server so they need to be saved on the client side(my computer) and the browser needs to load my scripts instead.
It shouldn't be hard to do at all but I've not been able to find any way to accomplish this.
Edit:
I want to modify the javascript's from a site I do not own or have write access too. e.g.,
Html page uses some javascript page on server. I want to modify this javascript file(the actual file).
I can download and save the javascript file BUT the html page will always use the one on the server because that is what is in the script tag. I need to modify the script tag of the html page to point to the local javascript file BEFORE the html page's scripts are executed(else the javascript from the server will be used).
here, for example, is a script tag from SE:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
It uses a non-local javascript file. I need to replace this line with my own line before any javascript is executed. It would like like:
<script type="text/javascript" src="file://C:/temp/myjquery.min.js"></script>
or whatever. (this way, I can modify the jquery file and have it execute my own version of the one on the server)
I, could, ofcourse, download the html file and modify it BUT then php code may not work among other things. (for example, relative links will be broke)
this is usually very easy in Opera: Just view source, edit what you want and use the special "Tools > Advanced > Reload from cache" command instead of a normal reload. Voila, you'll be running the site with your modified scripts..
(There are some exceptions, related to specific no-caching techniques some sites use it won't work 100% for all files - but it certainly should work for anything served from googleapis.com)
I think what you're looking for is something like LiveReload
It allows you to edit css files and have the browser apply the changes without refreshing the browser.
The windows version is in alpha right now but the Mac version works quite well for CSS.
I don't know if it does Javascript but I think it might.
You could also try the Chrome DevTools. It's a chrome extension that does just what you want with javascript and css.
No problem, you want to use bookmark-lets for this. Indeed it is easy, just remember to use an anonymous autoexecuting function: javascript:(function(){ //commands })();
In the sane good old day's one could even place this javascript directly into your addresses, but nowaday's some browser-builders (like firefox we coders USED to trust in the old day's) are being a 'good boy' and listen to facebook's 'demands' to kill normal standard functionality in favor of their lack on comprehending closures... But alas..
Ofcourse you could also create a bookmark to fix firefox's insanity, again reclaiming power to the user :)
Every time you visit the site, you click your bookmarklet. Done.
One can even make it 'memory resistant' for as long als you are on the same page (if you really want to). Naturally power is with the user/visitor AS IT SHOULD BE, not with the webmaster (who already publicly shared whatever info).
You might also look into greasemonky on firefox and comparable solutions.
Good luck
Build a string on the server side to write all your javascript code on the server side.
Are search-bot or spam-bots able to emulate/trigger JavaScript events while they read out the page?
No, because search bots fetch a static HTML stream. They aren't running any of the initialization events like init() or myObj.init(), which is in your JavaScript code. They don't load any external libraries like jQuery, nor execute the $(document).ready code nor any of the standard .click() listeners. So unless a search bot author has a specific reason to intentionally build their search bot to trigger or execute <script> blocks which are on the page, they usually won't run JavaScript code.
I've written a search bot. All that I care about is extracting the links & text from the page. However, I don't want to run someone else's client-side calendar component nor video player component. I don't want that JS code to be inserted into my database, where it could end up on the Search Engine Results Page (SERP). So there is no reason to run an eval() command on any code in the <script> blocks, nor trigger any of the initialization events in the JS layer.
When search bots load the HTML DOM, there are usually embedded external .js files in them. So to execute the JS would require parsing out the strings for multiple .js files, then building a concatenator for those files & then trying to execute everything that's been downloaded. That's extra work for a search bot author, for no net gain at all. We simply don't want that JS code to appear anywhere in our SERPs. Otherwise, seeing JS code on the SERP looks like a bad search result. However, bots can see content in <script> tags & are only looking for links to crawl. So that may be why people start to think that bots can execute JavaScript, but they are only really parsing them for their text links.
Here’s someone who makes the case that Google is loading pages in a headless WebKit when crawling them to get a chance to index AJAX content and for other reasons. Search bots don’t generally submit forms though.
I’ve taken a look at your site and the protection is entirely client-side. Since an HTML form really is just a description of what key/values to submit to some URL, there’s no reason anyone couldn’t just POST this data with a bot.
Example:
POST /contact
/* ... */
fullname=SO+test&email=test%40example.com&reason=test&message=test
Also, and this is important, you are penalising legitimate visitors this way. There’s all kind of reasons why JavaScript could be blocked, fail to load, or simply not work.
As part of a job I'm doing on a web site I have to copy a few thousand lines of text from several pages of the old site and paste them into the HTML for the new site. The long and painstaking way of going to the old page and copying the many lines of text and then going to my editor and pasting it there line by line is getting really old. I thought of using injected JavaScript to do this but I'm not quite sure where to start. Thanks in advance for any help.
Here are links to a page of the old site and a page of the new site. As you can see in the tables on each page it would take a ton of time to copy it all manually.
Old site: http://temp.delridgelegalformscom.officelive.com/macorporation1.aspx
New Site: http://ezwebsites.us/delridge/macorporation1.html
In order to do this type of work, you need two things: a way of injecting or executing your script on that page, and a good working knowledge of the Document Object Model for the target site.
I highly recommend using the Firefox plugin FireBug, or some equivalent tool on your browser of choice. FireBug lets you execute commands from a JavaScript console which will help. Hopefully the old site does not have a bunch of <FONT>, <OBJECT> or <IFRAME> tags which will make this even more tedious.
Using a library like Prototype or JQuery will also help selecting parts of the website you need. You can submit results using JQuery like this:
$(function() {
snippet = $('#content-id').html;
$.post('http://myserver/page', {content: snippet});
});
A problem you will very likely run into is the "same origination policy" many browsers enforce for JavaScript. So if your JavaScript was loaded from http://myserver as in this example, you would be OK.
Perhaps another route you can take is to use a scripting language like Ruby, Python, or (if you really have patience) VBA. The script can automate the list of pages to scrape and a target location for the information. It can just as easily package it up as a request to the new server if that's how pages get updated. This way you don't have to worry about injecting the JavaScript and hoping all works without problems.
I think you need Grease Monkey http://www.greasespot.net/