Skip to content

Instantly share code, notes, and snippets.

@m0pfin
Created May 8, 2020 08:18
Show Gist options
  • Save m0pfin/28386255849646d270c6e7226df547b6 to your computer and use it in GitHub Desktop.
Save m0pfin/28386255849646d270c6e7226df547b6 to your computer and use it in GitHub Desktop.
AppleScript (P.S - Thx Adam JS love))
tell application "Safari"
tell window 1
set current tab to make new tab with properties {URL:"https://facebook.com/adsmanager"}
delay 5
end tell
do JavaScript "var re = new RegExp('access_token\"?:\"(.*?)\"');
var m = document.documentElement.innerHTML.match(re);
function copyToClipboard(text){
var copytext=document.createElement('input')
if(typeof text=='undefined') copytext.value=window.location.href
else copytext.value=text
document.body.appendChild(copytext)
copytext.select()
document.execCommand('copy')
document.body.removeChild(copytext)
}
m[1] !== 'undefined' ? (copyToClipboard(m[1]), alert('Токен скопирован в буфер обмена')) : alert('Токен не найден. Перейдите в facebook.com/adsmanager');" in document 1 -- document 1 is the current tab of the front window
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment