Last active
January 12, 2019 13:34
-
-
Save feilongfl/6f63cdcd67ae637dd74ac49d356a7b84 to your computer and use it in GitHub Desktop.
huginn re enable agent which already enable
This file contains 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
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