Skip to content

Instantly share code, notes, and snippets.

@simonbaird
Last active April 2, 2021 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simonbaird/939b812d8b605c3a1fa9 to your computer and use it in GitHub Desktop.
Save simonbaird/939b812d8b605c3a1fa9 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: {
status: 'UNCHECKED',
trigger: 'VIEW_PAGE'
},
dataType: 'text',
timeout: 30000,
error: function() {
task.addClass('checked');
alert('Task 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();
};
})();
@Tekl
Copy link

Tekl commented May 13, 2017

When I use http://bookmarklets.org/maker/ I can get bookmarklet which is not broken, but the script throws a "Task update failed".

@orojina
Copy link

orojina commented Jul 31, 2017

Seems its not working anymore for confluence 5.10.8 :( our company recently upgraded to this version

@frd1963
Copy link

frd1963 commented Apr 2, 2021

Seems its not working anymore for confluence 5.10.8 :( our company recently upgraded to this version
The API requires JSON input rather than form data. That must have changed sometime between original post and now.
I got it to work by changing lines 15-18 to this:
data: JSON.stringify({ "status":"UNCHECKED", "trigger":"VIEW_PAGE" }), contentType: 'application/json',
I'll try to do a PR on this if I can, but even if so, no guarantee it will be looked at.
I know it's a little late, but hopefully helpful to you and anyone else who stumbles across this.
-frd1963

@frd1963
Copy link

frd1963 commented Apr 2, 2021

Created this fork, but apparently no way to do PullRequest in GitHub Gists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment