Created
January 31, 2021 18:14
-
-
Save lyo/44fb736eeb4a9aeda57a11a7d6354e2e 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_rev11618.user.js Sun May 18 13:57:18 2008 | |
| +++ reblogcommand_add_privatemode.user.js Sun May 18 15:37:53 2008 | |
| @@ -1,8 +1,9 @@ | |
| // ==UserScript== | |
| -// @name ReblogCommand | |
| -// @namespace http://white.s151.xrea.com/ | |
| -// @include http://* | |
| -// @include https://* | |
| +// @name ReblogCommand_add_privatemode | |
| +// @namespace http://white.s151.xrea.com/ -> pathch(http://hoge.sub.jp/blog/archives/2008/05/privatereblogre.html) | |
| +// @include http://*.tumblr.com/* | |
| +// @include http://reader.livedoor.com/reader/* | |
| +// @include http://fastladder.com/reader/* | |
| // ==/UserScript== | |
| (function(){ | |
| @@ -84,7 +85,7 @@ | |
| return params; | |
| } | |
| -function createPostData(params){ | |
| +function createPostData(params, isPrivate){ | |
| var arr = []; | |
| for(var param in params){ | |
| if(param != "preview_post"){ | |
| @@ -94,12 +95,29 @@ | |
| arr.push("&"); | |
| } | |
| } | |
| + if(isPrivate){ | |
| + arr.push("post[is_private]=1"); | |
| + } | |
| return arr.join('') | |
| } | |
| 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 = 'Reblog ...'; | |
| + | |
| + if(isPrivate){ | |
| + message = 'Private ' + message; | |
| + } | |
| + | |
| with(D()){ | |
| d = Deferred(); | |
| if(!id){ | |
| @@ -107,7 +125,7 @@ | |
| return d; | |
| } | |
| } | |
| - window.Minibuffer.status('ReblogCommand'+id, 'Reblog ...'); | |
| + window.Minibuffer.status('ReblogCommand'+id, message); | |
| d = D(); | |
| var url = aURL; | |
| d.xhttp.get(url). | |
| @@ -117,9 +135,11 @@ | |
| return d.xhttp.get(url); | |
| }). | |
| next(function(res){ | |
| - return d.xhttp.post(url, createPostData( parseParams( convertToHTMLDocument(res.responseText)))); | |
| + return d.xhttp.post(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(url); | |
| d.call(); | |
| @@ -168,6 +188,15 @@ | |
| window.Minibuffer.execute(target_cmd + ' | reblog' + clear_pin); | |
| }}); | |
| + 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', | |
| @@ -198,24 +227,29 @@ | |
| urls = stdin.map(function(node){return node.href}); | |
| } | |
| - // reblog | |
| - if(args.length == 1 && args[0] == '-m'){ | |
| + // reblog | |
| + if(args.length > 0 && !(args[0] == '-m' || args[0] == '-p') ){ | |
| + console.log('unknown args...'); | |
| + }else if(args.length == 1 && args[0] == '-m'){ | |
| urls.forEach(reblogManually); | |
| - }else if(args.length){ | |
| - console.log('unknown args...'); | |
| - }else{ | |
| - urls = urls.filter(isTumblrUserURL); | |
| - if(!urls.length) return stdin; | |
| - var lst = urls.map(reblog); | |
| - if(lst.length > 1){ | |
| - with(D()){ | |
| - parallel(lst).wait(2). | |
| - next(function(){window.Minibuffer.status('ReblogCommand','Everything is OK', 1000)}); | |
| - } | |
| - } | |
| - } | |
| - return stdin; | |
| - } | |
| + }else{ | |
| + urls = urls.filter(isTumblrUserURL); | |
| + if(!urls.length) return stdin; | |
| + var lst; | |
| + if(args.length == 1 && args[0] == '-p') { | |
| + lst = urls.map(privateReblog); | |
| + } else { | |
| + lst = urls.map(reblog); | |
| + } | |
| + if(lst.length > 1){ | |
| + with(D()){ | |
| + parallel(lst).wait(2). | |
| + next(function(){window.Minibuffer.status('ReblogCommand','Everything is OK', 1000)}); | |
| + } | |
| + } | |
| + } | |
| + return stdin; | |
| + } | |
| }); | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment