Skip to content

Instantly share code, notes, and snippets.

@feilongfl
Last active January 12, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feilongfl/6f63cdcd67ae637dd74ac49d356a7b84 to your computer and use it in GitHub Desktop.
Save feilongfl/6f63cdcd67ae637dd74ac49d356a7b84 to your computer and use it in GitHub Desktop.
huginn re enable agent which already enable
var huginn = window.location.protocol + "//" + window.location.host
var auth_key = document.getElementsByName("csrf-token")[0].content;
function reenable(data,success,xhr){
if (success){
var $b = jQuery(data)
var $bdis = $b.find('#details').text()
var bdis = $bdis.replace(/[\s\S]+Working:[\s\S]+?(\w+)[\s\S]+/,"$1")
if ($b != "Disabled"){
$.post(url,"utf8=%E2%9C%93&_method=put&agent%5Bdisabled%5D=true&commit=Yes&authenticity_token=" + auth_key,function(data,success,xhr){
console.log("finish",url)
})
$.post(url,"utf8=%E2%9C%93&_method=put&agent%5Bdrop_pending_events%5D=0&agent%5Bdisabled%5D=false&commit=Yes&authenticity_token=" + auth_key,function(data,success,xhr){
console.log("finish",url)
})
}
}
}
for (var a in window.agentPaths) {
var url = huginn + window.agentPaths[a].match(/\/agents\/\d+/)[0]
console.log(a, url)
$.get(url,reenable)
//break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment