// ==UserScript== // @name Tada-lists more enhancer // @namespace http://d.hatena.ne.jp/snaka72/ // @include http://*.tadalist.com/lists/* // ==/UserScript== // prototype.js & script.aculo.us object var Ajax = unsafeWindow.Ajax; var Effect = unsafeWindow.Effect; var Element = unsafeWindow.Element; var self = unsafeWindow.TadaEnhancer = {}; self.selectedListId = null; self.taskMove = function(elem, to, itemId, title) { if (!to || to == "") { alert("Please select destination"); return; } if (currentListId() == to) { alert("Destination is same as CURRENT !¥n" + "Please select another destination."); return; } Effect.Methods.fade(elem); // copy task item new Ajax.Request( '/lists/' + to + '/items', { asynchronouse: false, evalScripts: false, evalJS: false, parameters: 'item[content]=' + encodeURIComponent(title) } ); // remove task item new Ajax.Request( '/lists/' + currentListId(), { method: 'put', asynchronouse: false, evalScripts: false, evalJS: false, parameters: "item[" + itemId + "][content]=" } ); } function addMenuItemBefore(element, newMenu) { element.parentNode.insertBefore(newMenu, element); } var selectedListId = null; var newMenu = $N('span', {}, [ "| ", $N('a', { id: "moveTo", class: 'admin', href: "javascript:void(0)", }, "Move") ]); // create & add "Move to.." button var lastMenu = document.getElementById("ThisListLinks"); var menuContainer = lastMenu.parentNode; menuContainer.appendChild(newMenu); menuContainer.insertBefore(newMenu, lastMenu); var moveTo = document.getElementById('moveTo'); moveTo.addEventListener('click', function moveToOnclick() { if (this.className.indexOf('donelink') > -1) { Effect.SlideUp(unsafeWindow.$('listSelectorInner')); Element.Methods.removeClassName(moveTo, 'donelink'); moveTo.innerHTML = "Move"; } else { if (!unsafeWindow.$('listSelectorInner')) { var nav = createContainer(); getListIdNames().forEach(function([id, name]) { nav.appendChild(createListSelector(id, name)); }); GM_addStyle(<>>); } // replace check event $X('//ul[@id="incomplete_items"]//input[@id="item_completed"]/..') .forEach(function(elem) { var content = elem.textContent.replace(/[¥s]+/g, ""); var itemId = elem.id.match(/[0-9]+/)[0]; //alert(content); var eventHandler = "TadaEnhancer.taskMove(this, " + "TadaEnhancer.selectedListId" + ", '" + itemId + "', '" + content + "'); return false;"; elem.setAttribute('onsubmit', eventHandler); }); // TOGGLE style Effect.SlideDown(unsafeWindow.$('listSelectorInner')); this.className += ' donelink'; moveTo.innerHTML = "I'm done moving"; } }, false); self.listIdNames = null; function getListIdNames() { if (self.listIdNames) return self.listIdNames; GM_xmlhttpRequest({ method:"GET", url:"http://" + location.host + "/lists", onload:function(resp) { //GM_log(resp.responseText); var items = resp.responseText.match(/