Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name feedly_jdownloader
- // @description feed URLs to JDownloader.
- // @include http://cloud.feedly.com/*
- // @include https://cloud.feedly.com/*
- // @version 1.0.0
- // ==/UserScript==
- // JDownloader2の拡張設定から以下の機能のチェックを外すことを推奨
- // Auto Package Matching Correction
- // => OFF
- (function(){
- var KEY_CODE = 190; // [.]ピリオドキー
- var DISPTIME = 500; // msec
- var CSS = [
- "#jddialog{ background-color: #333333; display: none; opacity: 0.8; color: #fff; top: 50%; left: 50%; max-width: 600px; width: 600px; height: 50px; margin: -150px 0px 0px -200px; padding: 20px; text-align: center; font-size : 16px; font-weight: bold; z-index: 99999; position: fixed; -moz-user-select: none; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;}",
- ].join('');
- GM_addStyle(CSS);
- function showdialog(msg){
- var jddialog = document.getElementById("jddialog");
- if(!jddialog){
- var div = document.createElement("div");
- div.id = "jddialog";
- document.body.appendChild(div);
- jddialog = div;
- }
- jddialog.textContent= msg;
- jddialog.style.display = "block";
- window.setTimeout(function(){
- jddialog.style.display = "none";
- }, DISPTIME);
- }
- function form_encode(param){
- var buf = [];
- for(var key in param){
- var value = param[key];
- buf.push(
- encodeURIComponent(key)+"="+encodeURIComponent(value)
- )
- }
- return buf.join("&");
- }
- function getURLs(elm){
- var buf = [];
- var links = elm.getElementsByTagName("a");
- for(var i = 0; i < links.length; i++){
- // if(links[i].firstChild.nodeName === "#text")
- buf.push(links[i]);
- }
- return buf.join("\n");
- }
- function add_to_jdownloader(){
- var entryLists = document.getElementsByClassName("entryList");
- if(!entryLists) return;
- var entry = (entryLists[0].getElementsByClassName("selectedEntry") && entryLists[0].getElementsByClassName("selectedEntry")[0]) ||
- (entryLists[0].getElementsByClassName("inlineFrame") && entryLists[0].getElementsByClassName("inlineFrame")[0]);
- if(!entry) return;
- var title = entry.getElementsByClassName("title")[0].textContent;
- var body = entry.getElementsByClassName("content")[0];
- var postdata = form_encode({
- source: "feedly",
- package: title,
- urls: getURLs(body),
- // fnames: "",
- // apass: archivepass, // archive pass
- // dpass: "", // download pass
- // autostart: "0", // 0 or 1
- // referer: "",
- // descriptions: ""
- });
- GM_xmlhttpRequest({
- method: "post",
- headers: {"Content-type": "application/x-www-form-urlencoded"},
- url: "http://127.0.0.1:9666/flash/add",
- data: postdata,
- onload: function(res){
- if(res.status === 200 && res.responseText.indexOf("success") > -1){
- showdialog("JDownloader : " + title);
- }else{
- showdialog("JDownloader : Failed - " + res.status + " " + res.statusText);
- }
- },
- onerror: function(res){
- showdialog("JDownloader : Error - " + res.status + " " + res.statusText);
- }
- });
- }
- document.addEventListener("keydown", function(e){
- if(e.keyCode === KEY_CODE &&
- !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey &&
- !/^input|^textarea/i.test(e.target.tagName)){
- add_to_jdownloader();
- }
- }
- );
- })();
Add Comment
Please, Sign In to add comment