From: Thorsten Sperber Date: Mon, 22 Dec 2014 18:54:46 +0000 (+0100) Subject: init X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=e619a499318681bfda40ba4a4349e6d351a58dc4;p=dfde%2Fnopaste-affenscript.git init --- e619a499318681bfda40ba4a4349e6d351a58dc4 diff --git a/nopaste.user.js b/nopaste.user.js new file mode 100644 index 0000000..ffd7468 --- /dev/null +++ b/nopaste.user.js @@ -0,0 +1,55 @@ +// ==UserScript== +// @name debianforum.de-nopaste-addition +// @namespace org.free.for.all +// @require http://code.jquery.com/jquery-latest.min.js +// @include /^https?://debianforum\.de/forum/posting\.php.*/ +// @author Thorsten Sperber +// @version 0.3 +// ==/UserScript== + + +_log = console.log; + +$("#format-buttons").append(''); + +function replaceIt(txtarea, newtxt) { + $(txtarea).val( + $(txtarea).val().substring(0, txtarea.selectionStart)+ + newtxt+ + $(txtarea).val().substring(txtarea.selectionEnd) + ); +} +function getMessageText (ta) { return ta.value.substring(ta.selectionStart, ta.selectionEnd); } +function successPost(data, textStatus, jqXHR) + { + var pasteID = $(data).find('a[href^="./pastebin.php?mode=view"]'); + pasteID = pasteID.attr("href").substr(pasteID.attr("href").lastIndexOf("=")+1); + // _log("pasteID: " + pasteID); + replaceIt($('#message')[0], '[np]' + pasteID + '[/np]'); + } + +$("#nopaster").click(function() + { + var url = "//debianforum.de/forum/pastebin.php"; + var data = + { + snippet_title: $("#subject").val(), + snippet_desc: window.location.href, + snippet_highlight: "text", + fileupload: null, + snippet_text: getMessageText($("#message")[0]), + mode: "post", + submit: "Absenden" + }; + + // _log(data); + + $.ajax( + { + type: 'POST', + url: url, + data: data, + dataType: "html", + success: successPost + }) + });