User:קיפודנחש/pageCollector.js

(function {   function save(title, content, next)	{		var param = {action: 'edit', title: title, summary: 'adding ' + content, token: mw.user.tokens.get('csrfToken'), appendtext: content, format: 'json'};		$.post(mw.util.wikiScript('api'), param, function { mw.util.jsMessage(content + ' added to page ' + title); }); //flying blind	}	function add_button(page, caption)	{		var addColon = $.inArray(mw.config.get('wgNamespaceNumber'), [6,14]) + 1; //file:, category:		var pageName = (addColon ? ":" : "") + mw.config.get('wgPageName').replace( /_/g, " " );		var text =  + pageName + ;		var a = mw.util.addPortletLink(window.pageCollectorMenu || 'p-cactions','#',caption,'','add this page to: "' + page + '"');		$(a).click(function {save(page, '\n* ' + text);});	}    $(window.pagesToCollect).each(function {add_button(this.page, this.caption);}); });