Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name xfaqs quick edit
- // @namespace Kraust
- // @description port of the new quick edit script
- // @version 1
- // @grant none
- // ==/UserScript==
- // This should work with posts after the "Message Board Overhaul" release.
- // Thanks to kirbymuncher for the initial code that helped me design this script.
- // If you're interested in more please check out xfaqs @ http://xfaqs.nostlagiasky.pw
- // Changelog:
- // 2014-09-30: Script Created.
- var formatter = '<span class="tagbuttons"> \
- <input type="button" value="Bold" class="btn btn_mini btnbold" name="b" tabindex="-1"> \
- <input type="button" value="Italic" class="btn btn_mini btnitalic" name="i" tabindex="-1"> \
- <input type="button" value="Spoiler" class="btn btn_mini" name="spoiler" tabindex="-1"> \
- <input type="button" value="Cite" class="btn btn_mini btncite" name="cite" tabindex="-1"> \
- <input type="button" value="Quote" class="btn btn_mini" name="quote" tabindex="-1"> \
- <input type="button" value="Code" class="btn btn_mini btncode" name="code" tabindex="-1"> \
- </span>';
- var user = $(".welcome").text().slice(0, -1);
- var msgCount = $("td.msg").length;
- var reg = /\/(\d+)/g;
- var boardID = reg.exec(location.href)[1];
- var topicID = reg.exec(location.href)[1];
- function editCallback(i, messageID) {
- return function() {
- var postUrl = "/boards/post.php?board=" + boardID + "&topic=" + topicID + "&message=" + messageID;
- var msg = $('td.msg').eq(i).html();
- $.ajax({
- type: "POST",
- url: postUrl,
- async: false
- }).done(function(response) {
- var content = $(response).find('.body').eq(0).html();
- var textarea = $(response).find('.body textarea').eq(0);
- $(textarea).css("width", "100%");
- var key = response.match(/key" value="([^"]*)"/)[1];
- //var sig = $("[name=custom_sig]").val(); xfaqs rotating sigs
- $('td.msg').eq(i).html("<form id='qe-" + i + "' method='post' action='" + postUrl + "'><input type='hidden' value='" + key + "' name='key'><input type='hidden' value='Post without Preview' name='post'></form>");
- $("#qe-" + i).append(textarea);
- $("#qe-" + i).prepend(formatter);
- //$("#qe-" + i).append("<textarea type='hidden' name='custom_sig' style='width:100%'>" + sig + "</textarea>"); xfaqs rotating sigs
- $("#qe-" + i).append("<div style='display:block'><button class='btn btn_primary' id='editBtn-" + i + "'>Edit</button> <button class='btn' id='cancelBtn-" + i + "'>Cancel</button></div>");
- $('[name="b"]').click(function() {txtTagEdit('b');});
- $('[name="i"]').click(function() {txtTagEdit('i');});
- $('[name="spoiler"]').click(function() {txtTagEdit('spoiler');});
- $('[name="cite"]').click(function() {txtTagEdit('cite');});
- $('[name="quote"]').click(function() {txtTagEdit('quote');});
- $('[name="code"]').click(function() {txtTagEdit('code');});
- $("#cancelBtn-" + i).click(function() {
- $('td.msg').eq(i).html(msg);
- });
- }).error(function() {
- alert("Unable to edit post. This may be because you've edited your post the maximum amount of times, or your time limit has expired");
- });;
- }
- }
- for( var i = 0; i < msgCount; i++) {
- if( user == $(".name").eq(i).text() ) {
- var messageID = $(".msg_body").eq(i).attr('name');
- if($(".msg_stats_left").size() !== 0) {
- $("a.qq").eq(i).after(" - <a class='edit-" + i + "'>edit</a>");
- } else {
- $("a.qq").eq(i).after(" | <a class='edit-" + i + "'>edit</a>");
- }
- $(".edit-" + i).click(editCallback(i, messageID));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement