Sample Header Ad - 728x90

Ask Different (Apple)

Q&A for power users of Apple hardware and software

Latest Questions

1 votes
1 answers
717 views
How to move/hover mouse (not click) over a button on Safari by using Applescript
Can anybody tell me how to write an Applescript that can move or hover mouse over a Button on Safari? I've successfully made an Applescript that can click to the button but I don't know how to make the mouse just move there, not clicking. Because I need to download some images from a website that on...
Can anybody tell me how to write an Applescript that can move or hover mouse over a Button on Safari? I've successfully made an Applescript that can click to the button but I don't know how to make the mouse just move there, not clicking. Because I need to download some images from a website that only appear when you hover your mouse over that button (that button can't be clicked). The website I want to get information (HTML Element) when execute the script: https://shopee.vn/Bút-line-đi-nét-chuyên-nghiệp-SAKURA-PIGMA-MICRON-12-size-(0.03-Brush)-BÁN-LẺ-i.22061868.886461468 My sucessfull click-to-the-button Applescript (This click to the second image on the left): tell application "Safari" do JavaScript "document.getElementsByClassName('_3ZDC1p').click();" in document 1 end tell or: to clickClassName(theClassName, elementnum) tell application "Safari" do JavaScript "document.getElementsByClassName('" & theClassName & "')[" & elementnum & "].click();" in document 1 end tell end clickClassName clickClassName("_3ZDC1p", 2) So can you tell me how to hover mouse over the button (but not clicking) in a similar way of script like these above? Notice the Button "1.0 Graphic" in the website above is faded, that means it can't be clicked but once you hover your mouse to it, the image on the left appear, i want to get that image so bad. The url of that image only appear when I hover the mouse cursor over that button "1.0 Graphic". I already know how to make script downloading image from URL. I just need to have a script that can do hovering mouse to that button ("1.0 Graphic") so the image can be seen to grab the url. Thanks you!
Zui Zui (111 rep)
Jun 11, 2020, 06:36 AM • Last activity: Jun 16, 2025, 11:04 AM
0 votes
1 answers
447 views
AppleScript : do JS on different Safari windows
I'm using some script which basically get text from safari, click button and fill up textfield. e.g : tell application "Safari" set texttograb to do JavaScript "document.getElementsByClassName('the_variable_as_text')[0].value;" in document 1 do JavaScript "document.getElementsByClassName('text-entry...
I'm using some script which basically get text from safari, click button and fill up textfield. e.g : tell application "Safari" set texttograb to do JavaScript "document.getElementsByClassName('the_variable_as_text').value;" in document 1 do JavaScript "document.getElementsByClassName('text-entry').value=" & quoted form of myText in last tab of window 1 do JavaScript "document.getElementsByClassName('Approve-button').click();" in last tab of window 1 end tell This work perfectly but I have a change in my workflow and I need to use different safari window. How can I refer one javascript to one specific safari window and the other to a different window. Especially when some tab might have the same URL/Name ? I remember seeing that a while back (when the tab happen to have the same name but I never manage to run a script which refer to the window id Otherwise I suppose I can use another web browser (e.g one safari the second safari technology preview) as a workaround but that not really ideal and limit to two windows any idea how can I found the window ID and refer to it in AppleScript/JS ?
Kevin (2468 rep)
May 29, 2020, 08:35 AM • Last activity: Jun 5, 2025, 10:07 PM
3 votes
1 answers
4751 views
How can I create a shortcut to toggle javascript on/off in mobile Safari on my iPhone?
How can I create a shortcut to quickly toggle JavaScript off/on on my iPhone? I prefer to read the news with JavaScript disabled and then other websites, which typically require it to work, with it turned back on. Digging through the preferences to change this setting is tedious.
How can I create a shortcut to quickly toggle JavaScript off/on on my iPhone? I prefer to read the news with JavaScript disabled and then other websites, which typically require it to work, with it turned back on. Digging through the preferences to change this setting is tedious.
jimmont (1428 rep)
Jun 16, 2022, 04:43 AM • Last activity: Mar 3, 2025, 11:52 PM
1 votes
0 answers
418 views
Is there a method to have all links from a Chromium PWA application open in my default browser, Safari?
## Problem Statement On macOS, Is there a way to open all links from a Chromium PWA application in my default browser, Safari? Any advice or workarounds would be greatly appreciated. ## Scenario 1. Open Bing Chat Microsoft Edge's PWA application 2. Any link clicked to be opened in Safari application...
## Problem Statement On macOS, Is there a way to open all links from a Chromium PWA application in my default browser, Safari? Any advice or workarounds would be greatly appreciated. ## Scenario 1. Open Bing Chat Microsoft Edge's PWA application 2. Any link clicked to be opened in Safari application instead of Microsoft Edge ## Attempted Solutions I tried using **Choosy**, **Valjar**, and **Open In**. The only one that works but needs two clicks instead of one is **Choosy**, by right-clicking the link and pressing open in Choosy context menu. I thought of using Choosy API to prepend all links with Choosy using Tampermonkey user script. But I still cannot find a solid solution for my problem. ## Similar Threads/Posts https://apple.stackexchange.com/questions/448871/mac-os-open-links-from-chrome-pwas-in-default-browser-instead-safari - No responses. https://apple.stackexchange.com/questions/426786/how-to-open-https-links-which-are-part-of-a-webpage-in-firefox-or-chrome-in-th - Outdated, no-mention of chromium userscripts/tampermonkey with choosy API.
fatFeather (158 rep)
Dec 18, 2023, 10:15 PM • Last activity: Feb 13, 2025, 08:32 PM
2 votes
1 answers
506 views
Why am I getting “Unable to Run JavaScript on Web Page” in Apple Shortcuts, even though my script works?
I am trying the “Run JavaScript on Web Page” action in Apple Shortcuts with this simple script: ```javascript alert("test"); completion(result); ``` The alert fires and shows a message. However, I keep getting this error box at the end: *“Unable to Run JavaScript on Web Page. Make sure that ‘Allow J...
I am trying the “Run JavaScript on Web Page” action in Apple Shortcuts with this simple script:
alert("test");
completion(result);
The alert fires and shows a message. However, I keep getting this error box at the end: *“Unable to Run JavaScript on Web Page. Make sure that ‘Allow JavaScript from Apple Events’ is enabled in the Develop menu in Safari. The Develop menu can be enabled in the Advanced section of Safari’s Preferences.”* I’ve already verified and tried: 1. JavaScript is enabled in Safari. 2. The Develop menu is activated. 3. “Allow JavaScript from Apple Events” is checked. 4. Restarted both apps 5. Rebooted 6. Ran defaults write -app Safari AllowJavaScriptFromAppleEvents 1 What could be causing this issue, and how can I resolve it?
Tugrul Ates (151 rep)
Nov 27, 2024, 10:35 AM • Last activity: Nov 27, 2024, 10:48 AM
1 votes
0 answers
164 views
Definitive way to enable ESC-key-like functionality for Obsidian on iPhone
Has anyone provided a good solution to the lack of an escape key on iPhone yet, for vim mode? I feel like this needs a definitive solution, and I’d be willing to work on it if nobody has, yet. Not an external keyboard. Just a plugin that gives a good way to enter the escape character, like a special...
Has anyone provided a good solution to the lack of an escape key on iPhone yet, for vim mode? I feel like this needs a definitive solution, and I’d be willing to work on it if nobody has, yet. Not an external keyboard. Just a plugin that gives a good way to enter the escape character, like a special button above the keyboard, or a special character sequence that gets remapped to the ESC key code, etc. What strategy would be the best solution for implementing this, if writing an Obsidian plugin? Like, the most natural way to work within the confines of iOS, and not a kind of awkward workaround.
Julius Hamilton (385 rep)
Aug 13, 2024, 02:22 PM • Last activity: Oct 27, 2024, 01:49 PM
0 votes
0 answers
140 views
Add single bookmark button to top level macOS Safari toolbar
I would like to add a [bookmarklet](https://en.wikipedia.org/wiki/Bookmarklet) to my Safari window on macOS. I want the bookmarklet to be available as a button in the [top-level](https://lapcatsoftware.com/articles/blues.html) Safari toolbar, in the same toolbar as the Back/Forward buttons, address...
I would like to add a [bookmarklet](https://en.wikipedia.org/wiki/Bookmarklet) to my Safari window on macOS. I want the bookmarklet to be available as a button in the [top-level](https://lapcatsoftware.com/articles/blues.html) Safari toolbar, in the same toolbar as the Back/Forward buttons, address bar, Safari extension buttons, etc. enter image description here View > Customize Toolbar... does not seem to show any bookmark-related toolbar buttons for this toolbar I'm aware that I can View > Show Favorites Bar to display a full "Favorites" bookmark toolbar underneath the address bar. I can display and click a bookmarklet from this toolbar, and uncheck Show Title to [display only the favicon](https://apple.stackexchange.com/questions/143916/safari-display-favicons-in-favorites-bar) . enter image description here But I don't want to always see all of my other bookmarks in this bar, or waste the vertical space. I just want a single button next to the Address bar that opens a single bookmark / invokes a bookmarklet. How can I do this in Safari for macOS? If it cannot be done stock, are there any Safari Extensions that enable the functionality?
pkamb (9620 rep)
Aug 2, 2024, 06:36 PM • Last activity: Oct 17, 2024, 04:14 PM
0 votes
0 answers
299 views
Unresponsive website buttons on different Macs
There are buttons on some internal websites (can't provide an explicit link). Clicking most of them just gives no response at all in any browser (Firefox, Chrome, Safari, Edge) on all my different Macs. The buttons seem to be javascript buttons as mouse-over displays 'javascript:void(0);'. And I don...
There are buttons on some internal websites (can't provide an explicit link). Clicking most of them just gives no response at all in any browser (Firefox, Chrome, Safari, Edge) on all my different Macs. The buttons seem to be javascript buttons as mouse-over displays 'javascript:void(0);'. And I don't have any specific antivirus software installed. Looks a bit like this old post , but the solution there doesn't apply. These websites and buttons are being heavily used by many people (many are Windows). I happened to be able to confirm that some Apple Silicon user can use it without any problem. But not for me. I finally noticed the following option in Safari. > When we browse site A, there is an option `Safari --> > Settings for "address of site A" --> enable content blockers`. Unticking it helps my M2 Air to work. But this **does not** help for another Mac Studio or Intel iMac at all. And another guy's M-chip Air even works well with it ticked... I'm using the latest macOS and browsers. Any possible fix or direction? Thanks.
xiaohuamao (341 rep)
Sep 5, 2024, 03:41 AM • Last activity: Sep 15, 2024, 07:39 AM
5 votes
2 answers
3809 views
Make shortcut to enable/disable JavaScript with Safari 17.0
Safari 16.xx had an option `Disable JavaScript` in menu bar>Developers. I had a shortcut to simply enable/disable JavaScript with an easy shortcut. With Safari 17 Apple redesigned the developers section in Safari. The option to enable/disable JavaScript from the menu bar doesn't exist any more. Ther...
Safari 16.xx had an option Disable JavaScript in menu bar>Developers. I had a shortcut to simply enable/disable JavaScript with an easy shortcut. With Safari 17 Apple redesigned the developers section in Safari. The option to enable/disable JavaScript from the menu bar doesn't exist any more. Therefore, the shortcut doesn't work any more. Now, you can only enable/disable JavaScript within Safari preferences>Security>Enable JavaScript. Does anyone has an idea, how to receive the old behavior: enable/disable JavaScript with a simple shortcut?
David (290 rep)
Oct 8, 2023, 03:26 PM • Last activity: Sep 9, 2024, 03:15 AM
0 votes
1 answers
74 views
How do I get Ajax data in JavaScript for Automation?
I’m trying to write a simple script which reads one line of text from a remote server. The URL is something like: https://ajax.internotes.net/password/?password=Test@321 This returns a simple has of a password. Is it possible to do this in JXA? I’ve tried the usual Ajax methods using `fetch()` and e...
I’m trying to write a simple script which reads one line of text from a remote server. The URL is something like: https://ajax.internotes.net/password/?password=Test@321 This returns a simple has of a password. Is it possible to do this in JXA? I’ve tried the usual Ajax methods using fetch() and even XMLHttpRequest(), but they’re not available. Perhaps I can fake it with a call to the terminal? FWIW, I’m _not_ trying to use this for authentication. It’s just one step in longer process.
Manngo (3713 rep)
Jul 26, 2024, 12:52 AM • Last activity: Jul 27, 2024, 08:03 AM
3 votes
1 answers
157 views
Automator - Cyrillic symbols and file writing
I was quite surprised the fact that Apple Automator can make backups for my notes. So I wrote a small script for that. But there are two unsolved issues. 1. In for each files are creating but there are empty 2. The Cyrillic in files is writing like ????? 3. Is it possible somehow to get folder name...
I was quite surprised the fact that Apple Automator can make backups for my notes. So I wrote a small script for that. But there are two unsolved issues. 1. In for each files are creating but there are empty 2. The Cyrillic in files is writing like ????? 3. Is it possible somehow to get folder name to structure it with files like in Apple Note (Optional) Could you please help me with this? var app = Application.currentApplication() app.includeStandardAdditions = true function writeTextToFile(text, file, overwriteExistingContent) { try { var fileString = file.toString() var openedFile = app.openForAccess(Path(fileString), { writePermission: true }) if (overwriteExistingContent) { app.setEof(openedFile, { to: 0 }) } app.write(text, { to: openedFile, startingAt: app.getEof(openedFile) }) app.closeAccess(openedFile) return true } catch(error) { try { app.closeAccess(file) } catch(error) { console.log(Couldn't close file: ${error}) } return false } } var notesApp = Application('Notes'); notesApp.includeStandardAdditions = true; var notes = notesApp.notes; for(var i = 0; i < notes.length; i++) { try { var desktopString = app.pathTo("desktop").toString() var file = ${desktopString}/copy/${notes[i].name()}.txt var text = notes[i].body(); writeTextToFile(text, file, true) } catch(error) { var desktopString = app.pathTo("desktop").toString() var file = ${desktopString}/ERROR.log writeTextToFile(error.message, file, true) } }
dsjfhdjshfjkdshjf (31 rep)
Oct 5, 2022, 06:42 AM • Last activity: Feb 29, 2024, 09:06 AM
0 votes
1 answers
518 views
How can i open multiple instance of electron application in MAC OS?
i have an electron node application which i can open multiple instances in windows but not in MAC OS , how can i achieve the same functionality in mac also ?
i have an electron node application which i can open multiple instances in windows but not in MAC OS , how can i achieve the same functionality in mac also ?
satishVudata (1 rep)
Jan 30, 2024, 05:13 AM • Last activity: Jan 30, 2024, 07:36 AM
0 votes
1 answers
109 views
Since Spring, various websites have stopped working properly (on Safari and Opera) on my iPhone 8 running iOS 12
Since Spring, various websites have stopped working properly (on Safari and Opera) on my iPhone 8 running iOS 12. No problems on Android or MacOS. I suspect JavaScript (grey buttons don't go red when clicked, merely darker grey; popup menus don't popup; button have no effect etc). Are servers servin...
Since Spring, various websites have stopped working properly (on Safari and Opera) on my iPhone 8 running iOS 12. No problems on Android or MacOS. I suspect JavaScript (grey buttons don't go red when clicked, merely darker grey; popup menus don't popup; button have no effect etc). Are servers serving upgraded JavaScript code? Would upgrading to iOS 16 help? If possible I would like to avoid this because of other software becoming unavailable.
reallydismayed (170 rep)
Sep 1, 2023, 05:17 PM • Last activity: Sep 10, 2023, 03:03 PM
2 votes
0 answers
599 views
Capabilities of JavaScript in iOS Shortcuts
According to this: https://support.apple.com/en-eg/guide/shortcuts/apd218e2187d/ios And this: https://developer.apple.com/documentation/javascriptcore And this: https://medium.com/@chrishutchinson/hacking-around-with-javascript-and-shortcuts-in-ios-12-95f8d7190777 It seems like the JavaScript allowe...
According to this: https://support.apple.com/en-eg/guide/shortcuts/apd218e2187d/ios And this: https://developer.apple.com/documentation/javascriptcore And this: https://medium.com/@chrishutchinson/hacking-around-with-javascript-and-shortcuts-in-ios-12-95f8d7190777 It seems like the JavaScript allowed in apple applications like Scriptable and Shortcuts is like, “pure” JavaScript (as a programming language), which somehow does not support importing any modules or packages. The problem is I don’t know enough about how JavaScript works to grasp this intuitively. I am pretty sure Apple’s JavaScriptCore is syntactically based on ECMAScript 6 https://262.ecma-international.org/6.0/ . As far as I can tell, you cannot call fetch() in Scriptable, or in iOS Shortcuts’ “Run JavaScript on Webpage”. It implies there are some JavaScript classes or methods that are not available, but I don’t know how to anticipate which ones. How can I understand precisely specifically what JavaScript commands are supported and which aren’t, and why? Am I supposed to take WebKit as my documentation, perhaps? https://developer.apple.com/documentation/webkitjs https://webkit.org/blog/7536/jsc-loves-es6/ But if I am running JavaScript on a Safari page from iOS Shortcuts, wouldn’t I have full access to the client-side JavaScript capabilities of the browser, and doesn’t that naturally include basic Web APIs, like fetch()?
Julius Hamilton (385 rep)
Jun 2, 2023, 09:44 PM • Last activity: Jun 2, 2023, 09:56 PM
2 votes
0 answers
2243 views
Using Applescript to execute Javascript in Chrome and set a value to a variable
I'm building a service through Automator. So I'm trying to execute this bit of Javascript in Chrome and set the clipboard to the value of one of the variables. Essentially it is grabbing the contents of an element which is a file path. Ex: id:file:///Volumes/Imaging Share/TENNIS_2018/TW-07.23.18-[54...
I'm building a service through Automator. So I'm trying to execute this bit of Javascript in Chrome and set the clipboard to the value of one of the variables. Essentially it is grabbing the contents of an element which is a file path. Ex: id:file:///Volumes/Imaging Share/TENNIS_2018/TW-07.23.18--EleVen_Fila_Womens_Model/Capture/CaptureOne/Settings100/TWCES-GY-17057.CR2.cos stripping "id:file//" and then saving the remaining string in a variable or clipboard. The Javascript works if I execute it in the console but I'm not having any luck getting the Applescript to execute it and not quite sure how to get the value of the variable so it can be used later. here is the javascript by its self var link = document.getElementById('q'); var str = link.value.replace('id:file://', ''); console.log(str); here it is in the context of the Applescript which is not working tell application "Google Chrome" to activate tell application "Google Chrome" execute javascript ("var link = document.getElementById('q'); var str = link.value.replace('id:file://', ''); console.log(str); str.select(); document.execCommand('copy'); ") end tell Any help will be much appreciated.
Vasily Sidorenko (21 rep)
Aug 2, 2018, 04:08 PM • Last activity: May 20, 2023, 10:44 AM
1 votes
1 answers
93 views
What causes the "file" command to report a JavaScript file as "HTML document text"?
I downloaded a JavaScript document, but it fails to load in my webpage, stating that the mimetype of "" is not acceptable. When I use the file(1) command on the JavaScript file, it tells me that the file is "HTML document text". The file looks roughly like this: /* some boring attribution, etc. */ $...
I downloaded a JavaScript document, but it fails to load in my webpage, stating that the mimetype of "" is not acceptable. When I use the file(1) command on the JavaScript file, it tells me that the file is "HTML document text". The file looks roughly like this: /* some boring attribution, etc. */ $(function($) { a lot of javascript, including a few lines that add HTML to the page, such as _base.append(''); }(jQuery)); I know the file command uses various patterns to make its determination, I'm just wondering what it is that is triggering its decision.
user3481644 (148 rep)
Jan 24, 2022, 04:23 PM • Last activity: Apr 25, 2023, 08:04 PM
5 votes
1 answers
1412 views
Is there a manual for JavaScriptCore shell (jsc)?
MacOS ships with a JavaScript shell `jsc` in the JavaScriptCore framework. The easy way to run it from Terminal is to link it into a standard directory: ```ln -s /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc /usr/local/bin/jsc``` What built-in JavaScript functions does `jsc` supp...
MacOS ships with a JavaScript shell jsc in the JavaScriptCore framework. The easy way to run it from Terminal is to link it into a standard directory:
-s /System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc /usr/local/bin/jsc
What built-in JavaScript functions does jsc support? The [manual page](https://trac.webkit.org/wiki/JSC) documents some JavaScript functions like readline() and run(filename). But it's out of date — it's missing the command line options printed out by jsc --help. I found the the [source code](https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/jsc.cpp) to jsc. It sets up more JavaScript functions. Most of them look like testing and benchmarking hooks, but there some useful-looking functions like read and print. Are they documented anywhere?
Jay Lieske (425 rep)
Jun 23, 2018, 05:21 AM • Last activity: Mar 14, 2022, 08:00 PM
0 votes
1 answers
180 views
How to iterate over an Photos.app album (or a container) using Javascript?
How can I iterate over the media items of an album in Photos.app? By copying and editing online code, I got this far: ``` for (const album of Application("Photos").albums()) { console.log("Processing album '" + album.name() + "'") for (var idx in album) { console.log(idx) } } ``` However, this doesn...
How can I iterate over the media items of an album in Photos.app? By copying and editing online code, I got this far:
for (const album of Application("Photos").albums()) {
	console.log("Processing album '" + album.name() + "'")
	for (var idx in album) {
		console.log(idx)
	 } 
}
However, this doesn't work. I know that each album in Application("Photos").albums() is a container, but I couldn't find an example how to iterate over its content using javascript. In other code, I have already created a javascript Map where each key is the filename(+size+ratio) and it contains lists of duplicates (all but one to be deleted). Iterating through the albums, I want to extract the properties of the media items to check whether an item is to be deleted and if yes, replace them with the non-deleted duplicates. Any help or pointers to examples greatly appreciated!
Harmeling (111 rep)
Jan 3, 2022, 08:32 AM • Last activity: Jan 3, 2022, 03:34 PM
2 votes
2 answers
763 views
What is the javascript equivalent of the applescript run command?
I want to create a script for opening an app in nonstandard location quickly. With AppleScript, the app can be started with: ``` tell application [app path] to run ``` I want to do the same using javascript cause I am more familiar. But `Application([app path]).run()` does not work. In fact, the App...
I want to create a script for opening an app in nonstandard location quickly. With AppleScript, the app can be started with:
tell application [app path] to run
I want to do the same using javascript cause I am more familiar. But Application([app path]).run() does not work. In fact, the Application object does not seem to have any attributes.
cdowen (519 rep)
Dec 23, 2021, 09:58 AM • Last activity: Dec 24, 2021, 02:07 AM
1 votes
1 answers
1436 views
Parsing text, "line by line", with automator
I'm very new to programming so pardon me if this is a very simple question, but I'm trying to create an automator workflow where the variable would change with each loop, pulling the inputs from a textedit document. (and also, I'm creating the text edit document, so if formatting it differently woul...
I'm very new to programming so pardon me if this is a very simple question, but I'm trying to create an automator workflow where the variable would change with each loop, pulling the inputs from a textedit document. (and also, I'm creating the text edit document, so if formatting it differently would make this easier let me know) For example, I have a text edit document with several numbers, all 3 digits, separated by line breaks, like this: 001
005
009
013
014
021 I'd like automator to run a workflow the first time with the variable as "001", then again with variable as "005", then a 3rd time as "009" and so on. And if it makes things easier I can format it to be all on one line separated by commas, surrounded by brackets, whatever is best. I know a little bit of javascript and AppleScript, so if this is something solved with a run Javascript or AppleScript box, that is totally cool. Thanks!
Car_SharkHybrid (23 rep)
Jul 16, 2021, 06:56 AM • Last activity: Dec 13, 2021, 03:02 PM
Showing page 1 of 20 total questions