Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //* TITLE Queue Bottom **//
- //* VERSION 1.0.0 **//
- //* DESCRIPTION **//
- //* DEVELOPER Hannah **//
- //* FRAME false **//
- //* BETA true **//
- XKit.extensions.queue_bottom = new Object({
- running: false,
- button_icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QAsACwALDnu/73AAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4wMRDSUbmU8D/gAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACFSURBVDjL7dRRDsAQDAbgdtn99Ea4ESfsXjYhitUs2cM8ScSXUn6AxQOvCTNXizFGljYREbbAbXWFP/hBMLU/hGABwE06joh8UaExxk+CCauOPIEWmHiHCrTCmk25gYpYt8sdtIkNn42AdrFh2mSpY8+U8Y/iS/WgEd/5KfsoTLW/bnmFB7VLMHJKhEfZAAAAAElFTkSuQmCC",
- button_ok_icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QAsACwALDnu/73AAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4wMRDSUbmU8D/gAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACFSURBVDjL7dRRDsAQDAbgdtn99Ea4ESfsXjYhitUs2cM8ScSXUn6AxQOvCTNXizFGljYREbbAbXWFP/hBMLU/hGABwE06joh8UaExxk+CCauOPIEWmHiHCrTCmk25gYpYt8sdtIkNn42AdrFh2mSpY8+U8Y/iS/WgEd/5KfsoTLW/bnmFB7VLMHJKhEfZAAAAAElFTkSuQmCC",
- run: function() {
- this.running = true;
- if (!XKit.interface.where().queue) {
- // User is not in a queue, so we're done
- return;
- }
- XKit.tools.init_css("queue_bottom");
- XKit.extensions.queue_bottom.init();
- XKit.interface.create_control_button("bottom_button", this.button_icon, "Move to bottom", "", this.button_ok_icon);
- XKit.post_listener.add("queue_bottom", XKit.extensions.queue_bottom.add_button);
- XKit.extensions.queue_bottom.add_button();
- },
- init: function() {
- $(document).on("click", ".bottom_button", function(event) {
- // The blue background thing here is just from my debugging
- $(this).css("background","blue");
- var m_post = XKit.interface.post($(this));
- var post_id = $(this).attr('data-post-id');
- alert(post_id);
- var m_url = XKit.interface.where().user_url;
- alert(m_url);
- XKit.extensions.queue_bottom.queue_post(post_id, m_url);
- });
- },
- add_button: function() {
- $(XKit.interface.get_posts("has-bottom-button")).each(function() {
- // Add class so we won't hit this post again:
- $(this).addClass("has-bottom-button");
- // Adds the actual button
- XKit.interface.add_control_button(this, "bottom_button", "");
- });
- },
- queue_post: function(ID, m_url) {
- // This is all a slight edit of submit_shuffle_data() in ShuffleQueue.
- // In submit_shuffle_data(), there's an array of IDs, which are joined together
- // into a string with commas between them. This is just queueing one post
- // so I edited "encodeURIComponent" to just take the single post ID as an
- // argument. I also changed "post_ids=" to "post_id=" in GM_xmlhttpRequest
- // below, just as a guess, but it gives the same 403 error either way.
- // Lastly, "json" is false in the shufflequeue code: the only difference
- // I can tell is that the error code 403 doesn't seem to be specified
- // when json is false.
- var form_key = XKit.interface.form_key();
- var to_send_single = encodeURIComponent(ID);
- GM_xmlhttpRequest({
- method: "POST",
- url: "http://www.tumblr.com/blog/" + m_url + "/order_post_queue/",
- data: "post_ids=" + to_send_single + "&form_key=" + form_key,
- json: false,
- onerror: function(response) {
- XKit.window.show("Unable to queue post (ONERROR)", "Something went wrong. Sorry", "error", "<div class=\"xkit-button default\" id=\"xkit-close-message\">OK</div>");
- },
- onload: function(response) {
- if (response.status !== 200) {
- XKit.window.show("Unable to queue post", "Something went wrong. Sorry", "error", "<div class=\"xkit-button default\" id=\"xkit-close-message\">OK</div>");
- }
- }
- });
- },
- destroy: function() {
- XKit.post_listener.remove("queue_bottom");
- XKit.tools.remove_css("queue_bottom");
- this.running = false;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement