Created
May 18, 2020 21:06
-
-
Save m0pfin/de6699365a0f641a484a229f48387a96 to your computer and use it in GitHub Desktop.
AppleScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Отключаем уведомления в аккаунте | |
set myLink to "https://facebook.com/adsmanager" | |
tell application "Chromium" | |
activate | |
delay 2 | |
execute active tab of window 1 javascript "var rsa = new RegExp('selected_account_id\"?:\"(.*?)\"'); | |
var msa = document.documentElement.innerHTML.match(rsa); | |
var rat = new RegExp('access_token\"?:\"(.*?)\"'); | |
var mat = document.documentElement.innerHTML.match(rat); | |
if(msa !== null && mat !== null){ | |
var selAcc = msa[1]; | |
var accToken = mat[1]; | |
var xhr = new XMLHttpRequest(); | |
xhr.open(\"POST\", \"https://graph.facebook.com/v6.0/act_\"+selAcc, true); | |
xhr.setRequestHeader('Content-Type', 'application/json'); | |
xhr.onreadystatechange = function() { | |
if (this.readyState === 4){ | |
if(this.status == 200){ | |
var data = JSON.parse(this.responseText); | |
var status = data['success']; | |
alert(\"Уведомления для аккаунта: \"+selAcc+\" отключены (Статус выполнения запроса \"+status+\")\"); | |
}else{ | |
alert(\"произошла ошибка при отправке запроса\"); | |
} | |
} | |
}; | |
xhr.send(JSON.stringify({ | |
is_notifications_enabled: false, | |
access_token: accToken | |
})); | |
}else alert(\"Не найдены нужные данные для отправки запроса, перейдите в facebook.com/adsmanager/act_нужный аккаунт\");" | |
delay 4 | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment