How to execute Apple Script when click on HTML link? - javascript

I tried to embedded apple script in a link in HTML, but all it does is brought up the Apple Script Editor Application with profiled script in it.
I want it to execute after I click on the link - so I don't have to press the play button.
Can someone help me fix this real quick ?
link.html
<a href = "
applescript://com.apple.scripteditor?
action=new&script=
tell application %22Safari%22%0D%09
make new document with properties {URL:%22https://www.google.com%22}%0D%09
end tell ">
Click me to run the script !
</a>
Result:

You'll find your answer to your question here.
You'll also want to install the RCDefaults preference pane.
You have to use the full protocol, with the '?' and all that, in order to make your own protocol work as expected. You have to follow the scheme, or whatever that is called, for that kind of requests. The linktrigger demo at MaxOsXAutomation.com, worked for me, within the last month.

Related

How can I delay a new tab from loading with a userscript?

I use a userscript to modify the client-side code of a website. This code is adding an anchor tag to the page. Its target is _blank. The thing is that if I click this link too frequently, the site errors. A simple refresh on the new tab fixes the problem.
When I click on the link and it instantly opens a new tab. But I don't want that new tab to render until I visit it, or with some sort of time delay. Is there a way of achieving this?
I am using Firefox, so Firefox-only solutions are fine. I found this, but I don't see a way of using it to prevent the tab from rendering in the first place. When I Google for this, I see results about add-ons that can solve the problem. But, the links to them always 404. Ideally, the solution would only affect the tabs created by this script instead of the way all tabs work, but if the only way to do it is to affect the way all tabs work, I'd accept that as a solution.
The Tampermonkey documentation says there is a GM_openInTab function. It has a parameter called loadInBackground, but it only decides if the new tab is focused when you click the link.
If there is a way of making this new tab render some HTML of my choosing, I think that would be a neat solution. i.e., I'd write some HTML that, on focus, goes to the actual website's page. If this is an option, I'd need to know how to open a tab to HTML of my choosing in grease monkey.
(Just realization of idea you told in your question yourself)
You can place simple page that waits for focus and then redirects to what you pass in URL parameter somewhere and open in background tabs. Like:
load-url-from-search-on-focus.html?http://example.com:
<!doctype html>
<body
onload="document.title=u=location.search.slice(1)"
onfocus="u?document.location.replace(u):document.write('?search missing')">
Try it.
(data:uri could have been used instead of hosted page, if there weren't those pesky security precautions blocking rendering of top-level datauri navigations :|)

Enable right-click on a page (or image) of my website

I discovered this website while stuck on my own website development and couldn't find exactly the answer I am looking for.
I am using Photocrati to build a photographers website, and I need to enable right click on one page so visitors can download free pictures.
The page is the following : https://lacanneetletrepied.com/cadeau/
Unfortunately, the option "enable" or "disable" right click for the whole theme somehow doesn't function as it should. The right click is always disabled no matter how I change it.
This question has already been mainly answered on this topic : Enable Right Click Wordpress Site
The answer is globally the following : Just remove it from functions.php look for wp_enqueue_script().
But as I am new to website development (and quite new to development in general), I still have questions.
On my website, I press F12 to get the developers panel (on Chrome or Firefox, PC, W10).
But (this is where I am a complete beginner) : where can I find : wp_enqueue_script(), functions.php and how do I remove a JavaScript from there ?
Also, is mentionned the code : var photocrati_image_protection_global = {"enabled":"1"};
I can't find it either in the developers tab. Where can it be ? Do I need to both remove the JS and change the code ?
And finally, how can I make this modification happen only on the page I mentioned above ?
Finally, If you have a simple option to enable right click on the images of this page (https://lacanneetletrepied.com/cadeau/) , I would gladly take it :)
Thank you so much for your help.
Cypus

Need to open link in new tab and close current tab with one click

I find myself in need of a script to (1) open a link in a new tab and (2) close the current tab so the back button cannot be used to see the website that was previously being viewed. This is a security feature for a site, and unfortunately I'm at a complete loss. Nothing I've tried works and I don't know where to begin. This is likely very simple and is staring me in the face, but I don't normally find myself needing to use java for anything. Any ideas?
Its impossible, but as found in this thread how to stop browser back button using javascript you can prevent users from going back.
Theres a JS bin with an example
Edit - Please bear in mind the warning 'It is generally a bad idea overriding the default behavior of web browser.'

Initiate click event for every instance of an element

I am trying to initiate a click event for multiple instances of an element with a javascript bookmarklet. My goal is to be able to click on the bookmarklet and have it delete specific elements, such as whenever a button says remove. Could you help me with this please, I have tried vark.com and other sources to find this answer.
My goal is to achieve this in Google Chrome, can you help me?
Updated: Here is a more detailed explanation
<a class="page_link" title="Visit Page" href="http://www.jitbit.com/macro-recorder/versionhistory/" target="_blank">Version History - Macro Recorder, Macro Program, Mouse...</a>
This can be found by having PageMonitor installed in Chrome, clicking options and inspect element where it shows the name of the site you are monitoring.
Example:
Version History - Macro Recorder, Macro Program, Mouse...<--- This is the link
advanced rename remove Last Check: 11 seconds ago.<--- These are the options
Perhaps nodes was the wrong term, let me see.
remove
Where it says remove, I would like to initiate a click event that will press the Remove button every time it occurs Screenshot of PageMonitor options window
Thanks for explaining what you want to do. Unfortunately, I don't think this is going to be possible. Playing with PageMonitor, it doesn't appear to be possible to execute javascript in the address bar (necessary to make a bookmarklet) and have it affect the extension page.
The code to implement the feature you want is very easy though, and they could probably just add it to the extension if you asked them to. Here's the code:
$('.stop_monitoring:not(:first)').click()
Sadly, as I said, I don't think you can bookmarkletify this due to zone restrictions. Unsafe browser JS is run in a different zone from trusted extension JS. Hope this helps. :/

How do I tell if external javascript is either not running or not echoing? And why

The code below works on one page, but not another page (the place it should be - the same place as on the other page) - is blank.
This code displays the facebook like button, and is copied verbatim from the facebook website.
The code is there - I checked "view page source" in Firefox, it just isn't doing anything.
I can put another script, the "find us on facebook" button, either directly above or below this code, and that shows up okay.
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like
href="http://www.facebook.com/pages/[our name]/[our number]" layout="box_count"
show_faces="false" width="50"></fb:like>
UPDATE
If I use the iframe code instead of the XFBML code from: http://developers.facebook.com/docs/reference/plugins/like/ then it works on both pages (but I can't format that right - Wordpress doesn't like iframes in widgets).
What is going on?
UPDATE
When I disable the Wordpress Facebook Share plugin this problem goes away. There may be a problem with double initialization of the Facebook SDK, as pointed out by Chris Livey below. Is there some html I can add before the "like" code to de-initialize the SDK?
Do you have firebug? If not I would recommend downloading it:
http://getfirebug.com/
It has a console that lets you know exactly what is going wrong in JavaScript land.
You mentioned Firefox. You should start with looking in the Tools | Error Console to see if any javascript errors occurred during the page load.
The next step is to get the firebug addon and use it to see what might be happening.
(removed update - info did not apply)
UPDATE:
Okay, the word press plug in clobbering you. If you are going to keep the word press plug in then remove this:
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
From your button code and everything should work just fine.
UPDATE 2:
From all of the comments, this issue boiled down to a word press plugin using it's own javascript definition for the FB object. Fortunately before creating that object it performs a test to see if FB is already defined.
The fix then is to add the correct FB script to the top of the page such that it is executed by the browser BEFORE the word press FB Share button plugin script. Because it is executed first, the word press plugin can't screw it up while continuing to function correctly.
This only works if the browser executes the scripts in the order seen on the page.
The real fix would be for the word press plugin to be modified to use the full FB object from connect.facebook.com instead of the smaller one it provides.

Categories