Skip to content

Instantly share code, notes, and snippets.

@frd1963
Forked from simonbaird/README.md
Last active April 2, 2021 18:02
Show Gist options
  • Save frd1963/ba1cd223d92d2416f1cb9f32c14e903b to your computer and use it in GitHub Desktop.
Save frd1963/ba1cd223d92d2416f1cb9f32c14e903b to your computer and use it in GitHub Desktop.
Bookmarklet for unchecking tasks in a Confluence document

If you want to uncheck all the checkboxes in a Confluence page with many tasks in it then try this bookmarklet.

Go to Bookmarklet Crunchinator (or similar) to generate a bookmarklet using the contents of src.js below.

See also this feature request.

Update: actually it's not working for me in a bookmarklet, but works fine from Scratchpad in Firefox.

(function(){
var uncheckTask = function(liElem) {
var task = jQuery(liElem);
if (!task.hasClass('checked')) return;
task.removeClass('checked');
var taskId = task.data('inline-task-id');
var pageId = task.closest('ul').attr('data-inline-tasks-content-id') || AJS.params.pageId;
var postUrl = AJS.contextPath() + '/rest/inlinetasks/1/task/' + pageId + '/' + taskId + '/';
jQuery.ajax({
type: 'POST',
url: postUrl,
data: JSON.stringify({
"status": "UNCHECKED",
"trigger": "VIEW_PAGE"
}),
contentType: 'application/json',
dataType: 'text',
timeout: 30000,
error: function() {
task.addClass('checked');
alert(`Task '${task.text()}' update failed!');
}
});
};
var getCheckedTasks = function() {
return jQuery('ul.inline-task-list > li.checked[data-inline-task-id]');
};
var doNext = function() {
var checkedTasks = getCheckedTasks();
if (checkedTasks.length == 0) {
alert("All done.")
return;
}
uncheckTask(checkedTasks.get(0));
// Be nice to Confluence and hopefully it won't run out of threads and die
setTimeout(doNext, 1000);
};
if (confirm('Found ' + getCheckedTasks().length + ' checked tasks. Uncheck them now?')) {
doNext();
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment