From e619a499318681bfda40ba4a4349e6d351a58dc4 Mon Sep 17 00:00:00 2001
From: Thorsten Sperber <mail@aero2k.de>
Date: Mon, 22 Dec 2014 19:54:46 +0100
Subject: [PATCH] init

---
 nopaste.user.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 nopaste.user.js

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('<input type="button" class="button2" name="addbbcodeNOPASTE" value="NoPaste" id="nopaster" title="Pasta">');
+
+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
+        })
+    });
-- 
2.39.5