]> git.aero2k.de Git - dfde/nopaste-affenscript.git/commitdiff
init
authorThorsten Sperber <mail@aero2k.de>
Mon, 22 Dec 2014 18:54:46 +0000 (19:54 +0100)
committerThorsten Sperber <mail@aero2k.de>
Mon, 22 Dec 2014 18:54:46 +0000 (19:54 +0100)
nopaste.user.js [new file with mode: 0644]

diff --git a/nopaste.user.js b/nopaste.user.js
new file mode 100644 (file)
index 0000000..ffd7468
--- /dev/null
@@ -0,0 +1,55 @@
+// ==UserScript==\r
+// @name          debianforum.de-nopaste-addition\r
+// @namespace     org.free.for.all\r
+// @require       http://code.jquery.com/jquery-latest.min.js\r
+// @include       /^https?://debianforum\.de/forum/posting\.php.*/\r
+// @author        Thorsten Sperber\r
+// @version       0.3\r
+// ==/UserScript==\r
+\r
+\r
+_log = console.log;\r
+        \r
+$("#format-buttons").append('<input type="button" class="button2" name="addbbcodeNOPASTE" value="NoPaste" id="nopaster" title="Pasta">');\r
+\r
+function replaceIt(txtarea, newtxt) {\r
+  $(txtarea).val(\r
+        $(txtarea).val().substring(0, txtarea.selectionStart)+\r
+        newtxt+\r
+        $(txtarea).val().substring(txtarea.selectionEnd)\r
+   );  \r
+}\r
+function getMessageText (ta) { return ta.value.substring(ta.selectionStart, ta.selectionEnd); }\r
+function successPost(data, textStatus, jqXHR)\r
+        {\r
+        var pasteID = $(data).find('a[href^="./pastebin.php?mode=view"]');\r
+        pasteID = pasteID.attr("href").substr(pasteID.attr("href").lastIndexOf("=")+1);\r
+        // _log("pasteID: " + pasteID);\r
+        replaceIt($('#message')[0], '[np]' + pasteID + '[/np]');\r
+        }\r
+        \r
+$("#nopaster").click(function()\r
+    {\r
+    var url = "//debianforum.de/forum/pastebin.php";\r
+    var data =\r
+        {\r
+        snippet_title: $("#subject").val(),\r
+        snippet_desc: window.location.href,\r
+        snippet_highlight: "text",\r
+        fileupload: null,\r
+        snippet_text: getMessageText($("#message")[0]),\r
+        mode: "post",\r
+        submit: "Absenden"\r
+        };\r
+    \r
+    // _log(data);\r
+    \r
+    $.ajax(\r
+        {\r
+        type: 'POST',\r
+        url: url,\r
+        data: data,\r
+        dataType: "html",\r
+        success: successPost\r
+        })\r
+    });\r