I want to use osascript or some other way to automate "Reset Advertising Identifier" is it possible?
MacOS – automating “Reset Advertising Identifier” is it possible
automationmacosprivacyscript
Related Solutions
The magic command is:
mdfind kMDItemCFBundleIdentifier = "com.zerotier.ZeroTierOne"
You can determine this by working backwards from mdls foo | grep kMDItemCF
So if you didn't know iPhoto's CF Bundle Identifier:
Mac:~ me$ mdls /Applications/iPhoto.app | grep kMDItemCF
kMDItemCFBundleIdentifier = "com.apple.iPhoto"
As an example in Google Chrome, using the URL of this question and setting the scroll to point to the question header of the page, use Chrome > View > Developer > Developer Tools ⌥⌘I to find the id
. In this case it's called question-header
.
You can also right-click and select Inspect from the context menu, which will bring up Developer Tools directly to that point in the code.
The following code will open this page and scroll to the question header.
set myURL to "http://apple.stackexchange.com/questions/276314/how-can-i-find-a-specific-javascript-identifier-of-a-website#276314"
tell application "Google Chrome"
activate
tell front window to set curTab to make new tab at after (get active tab) with properties {URL:myURL}
tell curTab
repeat while (loading)
delay 1
end repeat
-- scroll to the top of the question header.
execute javascript "e=document.getElementById('question-header');tTop=0; do {tTop +=e.offsetTop || 0; e=e.offsetParent} while(e); window.scrollTo(0,tTop);"
end tell
end tell
You can see in the code above that question-header
was swapped for twc-scrollabe
in the execute javascript ...
line of code.
You can also get a quick list of the <div id=
anchor points using curl
in Terminal and piping the output to grep
, as in the example for this page.
$ curl -s 'http://apple.stackexchange.com/questions/276314/how-can-i-find-a-specific-javascript-identifier-of-a-website' | grep '<div id='
<div id="notify-container"></div>
<div id="custom-header"></div>
<div id="header">
<div id="hlogo">
<div id="hmenus">
<div id="content">
<div id="herobox">
<div id="hero-content">
<div id="close"><a title="click to minimize">_</a></div>
<div id="blurb">
<div id="desc">
</script> <div id="question-header">
<div id="mainbar">
<div id="comments-276314" class="comments dno">
<div id="comments-link-276314" data-rep=50 data-anon=true>
<div id="answers">
<div id="answers-header">
<div id="tabs">
<div id="answer-276316" class="answer" data-answerid="276316" itemscope itemtype="http://schema.org/Answer">
<div id="comments-276316" class="comments dno">
<div id="comments-link-276316" data-rep=50 data-anon=true>
<div id="post-editor" class="post-editor js-post-editor">
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<div id="draft-saved" class="draft-saved community-option fl" style="margin-top: 8px; height:24px; display:none;">draft saved</div>
<div id="draft-discarded" class="draft-discarded community-option fl" style="margin-top: 8px; height:24px; display:none;">draft discarded</div>
<div id="wmd-preview" class="wmd-preview"></div>
<div id="sidebar" class="show-votes">
<div id="hot-network-questions" class="module tex2jax_ignore">
<div id="feed-link">
<div id="feed-link-text">
<div id="footer" class="categories">
<div id="footer-menu">
<div id="footer-sites">
<div id="copyright">
<div id="svnrev">
<div id="additional-notices">
<div id="noscript-warning">Ask Different works best with JavaScript enabled<img src="https://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"></div>
$
Note: While curl
will bring the page down, the grep
command as shown in the example may not work as nice as it did for this page. Some page content doesn't have line breaks and the code is a contiguous stream.
Best Answer
Example #1 - via Googling
Googling I found this Reddit thread titled: I want to write auto reset script for Advertising Identifier.
The script from one of the replies in that thread is below.
NOTE: I did not test this, am merely sharing it as something that may help steer you in the right direction to ultimately getting a workable solution for you problem.
Script appears to be AppleScript.
Example #2 - I made using Automator
This is the first script I've ever done using Automator (be kind). I used the record button and clicked through the steps to construct a Workflow.
Automator WorkflowOnce I made he workflow I copy/pasted it into ScriptEditor.
Automator with stepsCopy/Paste from Automator → ScriptEditor
In ScriptEditor I could click the play button to run the script to debug it and see that it was working correctly.
ScriptEditor Play ButtonOne I had it working reasonably well, I put it into a Bash shell script so that I could run it standalone from a terminal.
And here's the finished Bash script with the
osascript
embedded within:To run this:
References