]> git.aero2k.de Git - dfde/quickmods.git/commitdiff
init
authorThorsten S <mail@aero2k.de>
Wed, 24 Dec 2014 10:08:17 +0000 (11:08 +0100)
committerThorsten S <mail@aero2k.de>
Wed, 24 Dec 2014 10:08:17 +0000 (11:08 +0100)
quickmod.user.js [new file with mode: 0644]

diff --git a/quickmod.user.js b/quickmod.user.js
new file mode 100644 (file)
index 0000000..33d3d88
--- /dev/null
@@ -0,0 +1,105 @@
+// ==UserScript==
+// @name          debianforum.de-quickmod-additions
+// @namespace     org.free.for.all
+// @require       http://code.jquery.com/jquery-latest.min.js
+// @include       /^https?://debianforum\.de/forum/viewtopic\.php.*
+// @author        Thorsten Sperber
+// @version       0.2
+// ==/UserScript==
+
+_log = console.log;
+ARCHIVFORUMID = 12;
+boardurl = "/";
+
+
+function get_post_id(_this) {
+    return $(_this).closest('.post').attr('id').slice(1);
+}
+
+function get_thread_id() {
+    return window.location.search.match('t=([0-9]+)')[1];
+}
+function get_forum_id() {
+    return window.location.search.match('f=([0-9]+)')[1];
+}
+function get_session_id() {
+    return $("a[href*='?sid']:last").attr("href").match("sid=([a-z0-9]+)")[1];
+}
+
+function removepost(event) {
+
+    _log(event);
+    var post_id = get_post_id(event.currentTarget);
+    var thread_id = get_thread_id();
+    _log(this);
+
+    var url = boardurl + "/mcp.php?&f=" + get_forum_id() + "&t=" + thread_id + "&i=main&mode=topic_view&action=split&start=0";
+    var data = {
+        "action": "split_all",
+        "icon": "1",
+        "mcp_topic_submit": "Submit",
+        "post_id_list[]": post_id,
+        "posts_per_page": "10",
+        "sd": "a",
+        "sk": "t",
+        "st": "0",
+        "st_old": "0",
+        "subject": "[spam] " + $('.topic-title a').text(),
+        "to_forum_id": ARCHIVFORUMID,
+        "to_topic_id": "0",
+    };
+    _log(data)
+    $.ajax(
+        {
+        type: 'POST',
+        url: url,
+        data: data,
+        dataType: "html",
+        error: function(a, b, c) {
+            _log(a, b, c);
+        },
+        success: function(data, status) {
+            key = data.match("confirm_key=([A-Z0-9]+)")[1];
+            _log(key);
+            _removepost(post_id, key);
+            }
+        }
+    );
+
+
+}
+ function _removepost(post_id, confirm_key) {
+    var thread_id = get_thread_id();
+    url = boardurl + "/mcp.php?action=split&f=" + get_forum_id() + "&i=main&mode=topic_view&start=0&t=" + thread_id + "&confirm_key=" + confirm_key;
+    data = {
+        "action": "split_all",
+        "confirm": "Yes",
+        "confirm_uid": "2",
+        "f": "0",
+        "i": "main",
+        "icon": "1",
+        "mode": "topic_view",
+        "post_id_list[0]": post_id,
+        "redirect": "/",
+        "sess": get_session_id(),
+        "start": "0",
+        "subject": "[spam] " + $('.topic-title a').text(),
+        "t": thread_id,
+        "to_forum_id": ARCHIVFORUMID
+    }
+
+    $.ajax(
+        {
+        type: 'POST',
+        url: url,
+        data: data,
+        dataType: "html",
+        success: function() { $('#p' + post_id).fadeToggle(); }
+        }
+    );
+
+}
+$('.locked-icon').remove();
+$(".post-buttons").off('click');
+$(".post-buttons").append('<li>').append('<a class="button icon-button locked-icon" name="spampost" title="Cut this shit">').on('click', removepost);
+