Created
January 28, 2021 16:16
-
-
Save lyo/237d03982930a79c74330c21d4586975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- reblogcommand.user.js Wed Apr 2 23:57:29 2008 | |
| +++ reblogcommand_with_privatemode.user.js Thu Apr 3 00:11:48 2008 | |
| @@ -1,7 +1,8 @@ | |
| // ==UserScript== | |
| -// @name ReblogCommand | |
| +// @name ReblogCommand_with_privatemode | |
| // @namespace http://white.s151.xrea.com/ | |
| -// @include * | |
| +// @include http://reader.livedoor.com/reader/* | |
| +// @include http://fastladder.com/reader/* | |
| // ==/UserScript== | |
| (function(){ | |
| @@ -66,7 +67,7 @@ | |
| return params; | |
| } | |
| -function createPostData(params){ | |
| +function createPostData(params, isPrivate){ | |
| var arr = []; | |
| for(param in params){ | |
| if(param != "preview_post"){ | |
| @@ -76,6 +77,9 @@ | |
| arr.push("&"); | |
| } | |
| } | |
| + if(isPrivate){ | |
| + arr.push("post[is_private]=1"); | |
| + } | |
| return arr.join('') | |
| } | |
| @@ -86,8 +90,24 @@ | |
| } | |
| function reblog(aURL){ | |
| + return _reblog(aURL, false); | |
| +} | |
| + | |
| +function privateReblog(aURL){ | |
| + return _reblog(aURL, true); | |
| +} | |
| + | |
| +function _reblog(aURL, isPrivate){ | |
| var id = getIDByPermalink(aURL); | |
| var d; | |
| + var message; | |
| + | |
| + if(isPrivate){ | |
| + message = 'Private Reblog ...'; | |
| + }else{ | |
| + message = 'Reblog ...'; | |
| + } | |
| + | |
| with(D()){ | |
| d = Deferred(); | |
| if(!id) { | |
| @@ -96,12 +116,12 @@ | |
| } | |
| } | |
| var url = getURLByID(id); | |
| - window.Minibuffer.status('ReblogCommand'+id, 'Reblog ...'); | |
| + window.Minibuffer.status('ReblogCommand'+id, message); | |
| getSource(url). | |
| next(function(res){ | |
| - return postData(url, createPostData( parseParams( convertToHTMLDocument(res.responseText)))); | |
| + return postData(url, createPostData( parseParams( convertToHTMLDocument(res.responseText)), isPrivate) ); | |
| }). | |
| - next(function(){ window.Minibuffer.status('ReblogCommand'+id, 'Reblog ... done.', 100); d.call()}). | |
| + next(function(){ window.Minibuffer.status('ReblogCommand'+id, message+' done.', 100); d.call()}). | |
| error(function(){ | |
| if(confirm('reblog manually ? \n' + url)) reblogManually(aURL); | |
| d.call(); | |
| @@ -147,6 +167,15 @@ | |
| }}); | |
| window.Minibuffer.addShortcutkey({ | |
| + key: 'y', | |
| + description: 'Private reblog', | |
| + command: function(){ | |
| + var target_cmd = getTargetCommand(); | |
| + var clear_pin = (target_cmd == 'pinned-or-current-link') ? ' | clear-pin' : ''; | |
| + window.Minibuffer.execute(target_cmd + ' | reblog -p' + clear_pin); | |
| + }}); | |
| + | |
| +window.Minibuffer.addShortcutkey({ | |
| key: 'T', | |
| description: 'Reblog manually', | |
| command: function(){ | |
| @@ -172,10 +201,20 @@ | |
| } | |
| // reblog | |
| - if(args.length = 1 && args[0] == '-m'){ | |
| + if(args.length == 1 && args[0] == '-m'){ | |
| urls.forEach(function(aURL){ | |
| reblogManually(aURL); | |
| }); | |
| + }else if(args.length == 1 && args[0] == '-p'){ | |
| + urls = urls.filter(isTumblrUserURL); | |
| + if(!urls.length) return stdin; | |
| + var lst = urls.map(privateReblog); | |
| + if(lst.length > 1){ | |
| + with(D()){ | |
| + parallel(lst).wait(2). | |
| + next(function(){window.Minibuffer.status('ReblogCommand','Everything is OK', 1000)}); | |
| + } | |
| + } | |
| }else if(args.length){ | |
| console.log('unknown args...'); | |
| }else{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment