diff --git a/safari2aria.safariextension/Info.plist b/safari2aria.safariextension/Info.plist index bfc5d75..ba80810 100644 --- a/safari2aria.safariextension/Info.plist +++ b/safari2aria.safariextension/Info.plist @@ -13,9 +13,9 @@ CFBundleInfoDictionaryVersion 1.0 CFBundleShortVersionString - 2.8 + 2.8.1 CFBundleVersion - 2.8 + 2.8.1 Chrome Database Quota @@ -87,7 +87,7 @@ Update From Gallery Update Manifest URL - https://miniers.github.io/safari2aria/update.plist?t=2.8 + https://miniers.github.io/safari2aria/update.plist?t=2.8.1 Website https://github.com/miniers/safari2aria diff --git a/safari2aria.safariextension/global.html b/safari2aria.safariextension/global.html index c652bd9..db2eb99 100644 --- a/safari2aria.safariextension/global.html +++ b/safari2aria.safariextension/global.html @@ -8,5 +8,5 @@
- + diff --git a/safari2aria.safariextension/static/js/endscript.js b/safari2aria.safariextension/static/js/endscript.js index a1a4804..be1d17f 100644 --- a/safari2aria.safariextension/static/js/endscript.js +++ b/safari2aria.safariextension/static/js/endscript.js @@ -1 +1 @@ -webpackJsonp([3],{146:function(e,t,n){"use strict";function o(e,t){var n=0;return new window.Promise(function(o,i){var a=function(e){var a=document.querySelector(e);return a&&t&&"none"==a.style.display?++n>20&&(i(!1),!0):(o(a),!0)},c=setInterval(function(){a(e)&&clearInterval(c)},500)})}function i(e,t){e.value=t;var n=/^magnet|torrent$/.test(e.value);$("#newoffline-dialog").find("span:contains('确定')[class='text']").click(),n&&o("#offlinebtlist-dialog",!0).then(function(e){"文件名"==$(".content-title-name").html()&&$("a.checked-all")[0].click(),e.querySelectorAll(".dialog-footer>.g-button")[1].click()});!function e(){o("#offlinelist-dialog",!0).then(function(){i()}),o("#dialog1",!0).then(function(t){var n=t.find(".input-code"),o=void 0;n.focus(),o=setInterval(function(){4==n.val().length&&(clearInterval(o),$("#dialog1").find("span:contains('确定')[class='text']").click(),e())},200)})}()}t.a=function(e){document.querySelector(".g-button[data-button-id=b13]").click(),o("#_disk_id_2").then(function(e){return e.click(),o("#share-offline-link")}).then(function(t){i(t,e)})}},153:function(e,t,n){var o,i,a;!function(n,c){i=[],o=c,void 0!==(a="function"==typeof o?o.apply(t,i):o)&&(e.exports=a)}(0,function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};return function(){function n(e,t){var o=this;e.style.opacity&&e.style.opacity>.05?e.style.opacity=e.style.opacity-.05:e.style.opacity&&e.style.opacity<=.1?e.parentNode&&(e.parentNode.removeChild(e),t&&t()):e.style.opacity=.9,setTimeout(function(){return n.apply(o,[e,t])},1e3/30)}function o(e,n,i){n=n||{},i=i||"";for(var a in e)if(e.hasOwnProperty(a)){var c=e[a];c&&"object"===(void 0===c?"undefined":t(c))&&!(c instanceof Date||c instanceof RegExp)?o(c,n,i+a+" "):n[i]&&"object"===t(n[i])?n[i][a]=c:(n[i]={},n[i][a]=c)}return n}function i(e){var t=o(e),n=JSON.stringify(t,null,2);return n=n.replace(/"([^"]*)": \{/g,"$1 {").replace(/"([^"]*)"/g,"$1").replace(/(\w*-?\w*): ([\w\d .#]*),?/g,"$1: $2;").replace(/},/g,"}\n").replace(/ &([.:])/g,"$1"),n=n.substr(1,n.lastIndexOf("}")-1)}function a(e){var t=document.head||document.getElementsByTagName("head")[0],n=c("style");n.id="mini-toastr-styles",n.type="text/css",n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),t.appendChild(n)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div";return document.createElement(e)}function s(e,t,n){var o=c(n.icons[t].nodeType),i=n.icons[t].attrs;for(var a in i)i.hasOwnProperty(a)&&o.setAttribute(a,i[a]);e.appendChild(o)}function r(e,t,n){var o=c();o.className=n,o.appendChild(document.createTextNode(t)),e.appendChild(o)}var u,d;if("undefined"==typeof window)return{init:function(){}};var l={error:"error",warn:"warn",success:"success",info:"info"},f={container:"mini-toastr",notification:"mini-toastr__notification",title:"mini-toastr-notification__title",icon:"mini-toastr-notification__icon",message:"mini-toastr-notification__message",error:"-"+l.error,warn:"-"+l.warn,success:"-"+l.success,info:"-"+l.info},p={types:l,animation:n,timeout:3e3,icons:{},appendTarget:document.body,node:c(),style:(d={},e(d,"."+f.container,{position:"fixed","z-index":99999,right:"12px",top:"12px"}),e(d,"."+f.notification,(u={cursor:"pointer",padding:"12px 18px",margin:"0 0 6px 0","background-color":"#000",opacity:.8,color:"#fff","border-radius":"3px","box-shadow":"#3c3b3b 0 0 12px",width:"300px"},e(u,"&."+f.error,{"background-color":"#D5122B"}),e(u,"&."+f.warn,{"background-color":"#F5AA1E"}),e(u,"&."+f.success,{"background-color":"#7AC13E"}),e(u,"&."+f.info,{"background-color":"#4196E1"}),e(u,"&:hover",{opacity:1,"box-shadow":"#000 0 0 12px"}),u)),e(d,"."+f.title,{"font-weight":"500"}),e(d,"."+f.message,{display:"inline-block","vertical-align":"middle",width:"240px",padding:"0 12px"}),d)},m={config:p,showMessage:function(e,t,n,o,i,a){var u={};Object.assign(u,this.config),Object.assign(u,a);var d=c();return d.className=f.notification+" "+f[n],d.onclick=function(){u.animation(d,null)},t&&r(d,t,f.title),u.icons[n]&&s(d,n,u),e&&r(d,e,f.message),u.node.insertBefore(d,u.node.firstChild),setTimeout(function(){return u.animation(d,i)},o||u.timeout),i&&i(),this},init:function(e){var t=this,n={};return Object.assign(n,p),Object.assign(n,e),this.config=n,a(i(n.style)),n.node.id=""+f.container,n.node.className=""+f.container,n.appendTarget.appendChild(n.node),Object.keys(n.types).forEach(function(e){m[n.types[e]]=function(t,o,i,a,c){return this.showMessage(t,o,n.types[e],i,a,c),this}.bind(t)}),this},setIcon:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"i",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];n.class=n.class?n.class+" "+f.icon:f.icon,this.config.icons[e]={nodeType:t,attrs:n}}};return m}()})},157:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(153),i=n.n(o),a=n(146),c=n(36),s=n(37);window.top===window&&function(){function e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=p.language||navigator.language;return g[n]&&g[n][e]?[g[n][e]," "].join(""):t.notfailback?"":[e," "].join("")}function t(){var e=window.getSelection().toString();return e.match(/^https?/)||e.match(/magnet:/)?e:null}function o(e){var t=null;return"BODY"===e.tagName?t=null:"IMG"===e.tagName&&e.src?t=e.src:e.href?t=e.href:e.parentNode&&(t=o(e.parentNode)),t}function r(t){n.i(s.a)({listeners:[{name:"changeRpc",cb:function(t){i.a.success(e("Success switch the default download service to")+t)}},{name:"currentRpc",cb:function(t){i.a.success(e("The current download service is")+t)}},{name:"showMassage",cb:function(e){i.a[e.action||"success"](e.text,e.title)}},{name:"baiduLixian",cb:function(e){location.href.match(/^https?:\/\/pan\.baidu\.com/)&&n.i(a.a)(e.url)}},{name:"sendToEndScript",cb:function(e){p=e,d(),safari.self.tab.dispatchMessage("documentReady",{cookie:document.cookie})}}]})}function u(e){var n=[o(e.target)||t(),document.location.href,document.cookie];safari.self.tab.setContextMenuEventUserInfo(e,n)}function d(){if(f)return void(p.catchIframe||f.disconnect());p.catchIframe&&(f=new MutationObserver(function(e){e.some(function(e){return!("IFRAME"!==e.target.tagName||"attributes"!==e.type||"src"!==e.attributeName||!n.i(c.a)(e.target.src,p,m))&&(!e.target.src.match(/^https:\/\/127\.0\.0\.1\//)&&(safari.self.tab.dispatchMessage("downloadFromIframe",{url:e.target.src,cookie:document.cookie}),e.target.src="https://127.0.0.1/",!1))})}),f.observe(document.body,{attributes:!0,attributeFilter:["src"],attributeOldValue:!0,characterData:!1,characterDataOldValue:!1,childList:!1,subtree:!0}))}function l(){m.isCommandPressed=!!m[91],m.isShiftPressd=!!m[16],m.isOptionPressd=!!m[18],safari.self.tab.dispatchMessage("keyPress",{keyPressed:m})}var f,p,m={},g={"zh-CN":{"Success switch the default download service to":"成功切换默认下载服务至","The current download service is":"当前下载服务为"}};document.onkeydown=function(e){var t=e.charCode?e.charCode:e.keyCode;m[t]=!0,l()},document.onkeyup=function(e){var t=e.charCode?e.charCode:e.keyCode;delete m[t],l()},window.onblur=function(e){m={},l()},function(){i.a.init({appendTarget:document.body,timeout:5e3}),document.addEventListener("contextmenu",u,!1),r(),l()}()}()},36:function(e,t,n){"use strict";function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e&&!n[82]&&t.enableTypefiles?!n.isCommandPressed:n.isCommandPressed){if(e.match(/magnet:[^\\"]+/))return!0;var o=e.substr(e.lastIndexOf(".")+1);o=o.toLowerCase();for(var i=t.filetypes?t.filetypes.split(" "):[],a=0;a0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(t,n){setTimeout(function(){n("timeout to get config")},1e4),window.extensionMessageListener||safari.self.addEventListener("message",function(e){var o=0;window.extensionMessageListener.forEach(function(n){e.name===n.name&&(n.cb&&n.cb(e.message||{}),t(e.message||{}),o++)}),o||n("no listener"),e.message&&e.message.hasCb&&safari.self.tab.dispatchMessage([e.name,"cb"].join("_"),{cookie:document.cookie})},!1),window.extensionMessageListener=[].concat(window.extensionMessageListener||[]).concat(e.listeners||[]),e.send&&e.send.forEach(function(e){safari.self.tab.dispatchMessage(e.name,e.params)})})}}},[157]); \ No newline at end of file +webpackJsonp([3],{146:function(e,t,n){"use strict";function i(e,t){var n=0;return new window.Promise(function(i,o){var a=function(e){var a=document.querySelector(e);return a&&t&&"none"==a.style.display?++n>20&&(o(!1),!0):(i(a),!0)},c=setInterval(function(){a(e)&&clearInterval(c)},500)})}function o(e,t){e.value=t;var n=/^magnet|torrent$/.test(e.value);$("#newoffline-dialog").find("span:contains('确定')[class='text']").click(),n&&i("#offlinebtlist-dialog",!0).then(function(e){"文件名"==$(".content-title-name").html()&&$("a.checked-all")[0].click(),e.querySelectorAll(".dialog-footer>.g-button")[1].click()});!function e(){i("#offlinelist-dialog",!0).then(function(){o()}),i("#dialog1",!0).then(function(t){var n=t.find(".input-code"),i=void 0;n.focus(),i=setInterval(function(){4==n.val().length&&(clearInterval(i),$("#dialog1").find("span:contains('确定')[class='text']").click(),e())},200)})}()}t.a=function(e){document.querySelector(".g-button[data-button-id=b13]").click(),i("#_disk_id_2").then(function(e){return e.click(),i("#share-offline-link")}).then(function(t){o(t,e)})}},150:function(e,t,n){"use strict";t.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(t,n){setTimeout(function(){n("timeout to get config")},1e4),window.extensionMessageListener||safari.self.addEventListener("message",function(e){var i=0;window.extensionMessageListener.forEach(function(n){e.name===n.name&&(document.hidden&&!n.background||(n.cb&&n.cb(e.message||{}),t(e.message||{}),i++))}),i||n(document.hidden?"in background":"no listener"),e.message&&e.message.hasCb&&safari.self.tab.dispatchMessage([e.name,"cb"].join("_"),{cookie:document.cookie})},!1),window.extensionMessageListener=[].concat(window.extensionMessageListener||[]).concat(e.listeners||[]),e.send&&e.send.forEach(function(e){safari.self.tab.dispatchMessage(e.name,e.params)})})}},153:function(e,t,n){var i,o,a;!function(n,c){o=[],i=c,void 0!==(a="function"==typeof i?i.apply(t,o):i)&&(e.exports=a)}(0,function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};return function(){function n(e,t){var i=this;e.style.opacity&&e.style.opacity>.05?e.style.opacity=e.style.opacity-.05:e.style.opacity&&e.style.opacity<=.1?e.parentNode&&(e.parentNode.removeChild(e),t&&t()):e.style.opacity=.9,setTimeout(function(){return n.apply(i,[e,t])},1e3/30)}function i(e,n,o){n=n||{},o=o||"";for(var a in e)if(e.hasOwnProperty(a)){var c=e[a];c&&"object"===(void 0===c?"undefined":t(c))&&!(c instanceof Date||c instanceof RegExp)?i(c,n,o+a+" "):n[o]&&"object"===t(n[o])?n[o][a]=c:(n[o]={},n[o][a]=c)}return n}function o(e){var t=i(e),n=JSON.stringify(t,null,2);return n=n.replace(/"([^"]*)": \{/g,"$1 {").replace(/"([^"]*)"/g,"$1").replace(/(\w*-?\w*): ([\w\d .#]*),?/g,"$1: $2;").replace(/},/g,"}\n").replace(/ &([.:])/g,"$1"),n=n.substr(1,n.lastIndexOf("}")-1)}function a(e){var t=document.head||document.getElementsByTagName("head")[0],n=c("style");n.id="mini-toastr-styles",n.type="text/css",n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),t.appendChild(n)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div";return document.createElement(e)}function s(e,t,n){var i=c(n.icons[t].nodeType),o=n.icons[t].attrs;for(var a in o)o.hasOwnProperty(a)&&i.setAttribute(a,o[a]);e.appendChild(i)}function r(e,t,n){var i=c();i.className=n,i.appendChild(document.createTextNode(t)),e.appendChild(i)}var u,d;if("undefined"==typeof window)return{init:function(){}};var l={error:"error",warn:"warn",success:"success",info:"info"},f={container:"mini-toastr",notification:"mini-toastr__notification",title:"mini-toastr-notification__title",icon:"mini-toastr-notification__icon",message:"mini-toastr-notification__message",error:"-"+l.error,warn:"-"+l.warn,success:"-"+l.success,info:"-"+l.info},m={types:l,animation:n,timeout:3e3,icons:{},appendTarget:document.body,node:c(),style:(d={},e(d,"."+f.container,{position:"fixed","z-index":99999,right:"12px",top:"12px"}),e(d,"."+f.notification,(u={cursor:"pointer",padding:"12px 18px",margin:"0 0 6px 0","background-color":"#000",opacity:.8,color:"#fff","border-radius":"3px","box-shadow":"#3c3b3b 0 0 12px",width:"300px"},e(u,"&."+f.error,{"background-color":"#D5122B"}),e(u,"&."+f.warn,{"background-color":"#F5AA1E"}),e(u,"&."+f.success,{"background-color":"#7AC13E"}),e(u,"&."+f.info,{"background-color":"#4196E1"}),e(u,"&:hover",{opacity:1,"box-shadow":"#000 0 0 12px"}),u)),e(d,"."+f.title,{"font-weight":"500"}),e(d,"."+f.message,{display:"inline-block","vertical-align":"middle",width:"240px",padding:"0 12px"}),d)},p={config:m,showMessage:function(e,t,n,i,o,a){var u={};Object.assign(u,this.config),Object.assign(u,a);var d=c();return d.className=f.notification+" "+f[n],d.onclick=function(){u.animation(d,null)},t&&r(d,t,f.title),u.icons[n]&&s(d,n,u),e&&r(d,e,f.message),u.node.insertBefore(d,u.node.firstChild),setTimeout(function(){return u.animation(d,o)},i||u.timeout),o&&o(),this},init:function(e){var t=this,n={};return Object.assign(n,m),Object.assign(n,e),this.config=n,a(o(n.style)),n.node.id=""+f.container,n.node.className=""+f.container,n.appendTarget.appendChild(n.node),Object.keys(n.types).forEach(function(e){p[n.types[e]]=function(t,i,o,a,c){return this.showMessage(t,i,n.types[e],o,a,c),this}.bind(t)}),this},setIcon:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"i",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];n.class=n.class?n.class+" "+f.icon:f.icon,this.config.icons[e]={nodeType:t,attrs:n}}};return p}()})},157:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(153),o=n.n(i),a=n(146),c=n(36),s=n(150),r=n(37);window.top===window&&function(){function e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=g.language||navigator.language;return b[n]&&b[n][e]?[b[n][e]," "].join(""):t.notfailback?"":[e," "].join("")}function t(){var e=window.getSelection().toString();return e.match(/^https?/)||e.match(/magnet:/)?e:null}function i(e){var t=null;return"BODY"===e.tagName?t=null:"IMG"===e.tagName&&e.src?t=e.src:e.href?t=e.href:e.parentNode&&(t=i(e.parentNode)),t}function u(e){console.log("disableBaiduLimit:",e.disableBaiduLimit),window.mDisableBaiduLimit=e.disableBaiduLimit}function d(t){n.i(s.a)({send:[{name:"getConfig"}],listeners:[{name:"changeRpc",cb:function(t){o.a.success(e("Success switch the default download service to")+t)}},{name:"currentRpc",cb:function(t){o.a.success(e("The current download service is")+t)}},{name:"showMassage",cb:function(e){o.a[e.action||"success"](e.text,e.title)}},{name:"baiduLixian",cb:function(e){location.href.match(/^https?:\/\/pan\.baidu\.com/)&&n.i(a.a)(e.url)}},{name:"updateConfig",background:!0,cb:function(e){g=e,f(),safari.self.tab.dispatchMessage("documentReady",{cookie:document.cookie}),location.href.match(/baidu/)&&n.i(r.a)(u,{disableBaiduLimit:g.disableBaiduLimit})}}]})}function l(e){var n=[i(e.target)||t(),document.location.href,document.cookie];safari.self.tab.setContextMenuEventUserInfo(e,n)}function f(){if(p)return void(g.catchIframe||p.disconnect());g.catchIframe&&(p=new MutationObserver(function(e){e.some(function(e){return!("IFRAME"!==e.target.tagName||"attributes"!==e.type||"src"!==e.attributeName||!n.i(c.a)(e.target.src,g,h))&&(!e.target.src.match(/^https:\/\/127\.0\.0\.1\//)&&(safari.self.tab.dispatchMessage("downloadFromIframe",{url:e.target.src,cookie:document.cookie}),e.target.src="https://127.0.0.1/",!1))})}),p.observe(document.body,{attributes:!0,attributeFilter:["src"],attributeOldValue:!0,characterData:!1,characterDataOldValue:!1,childList:!1,subtree:!0}))}function m(){h.isCommandPressed=!!h[91],h.isShiftPressd=!!h[16],h.isOptionPressd=!!h[18],safari.self.tab.dispatchMessage("keyPress",{keyPressed:h})}var p,g,h={},b={"zh-CN":{"Success switch the default download service to":"成功切换默认下载服务至","The current download service is":"当前下载服务为"}};document.onkeydown=function(e){var t=e.charCode?e.charCode:e.keyCode;h[t]=!0,m()},document.onkeyup=function(e){var t=e.charCode?e.charCode:e.keyCode;delete h[t],m()},window.onblur=function(e){h={},m()},function(){o.a.init({appendTarget:document.body,timeout:5e3}),document.addEventListener("contextmenu",l,!1),d(),m()}()}()},36:function(e,t,n){"use strict";function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e&&!n[82]&&t.enableTypefiles?!n.isCommandPressed:n.isCommandPressed){if(e.match(/magnet:[^\\"]+/))return!0;var i=e.substr(e.lastIndexOf(".")+1);i=i.toLowerCase();for(var o=t.filetypes?t.filetypes.split(" "):[],a=0;a1&&void 0!==arguments[1]?arguments[1]:{},n=D.language||navigator.language;return x()(A,[n,t],e.notfailback?"":[t," "].join(""))}function i(){var t={};D.rpcList.forEach(function(e,n){var o=e.url.match(/^(http|ws)(s)?(?:\:\/\/)(token\:[^@]*)?@?([^\:\/]*)\:?(\d*)(\/[^\/]*)/),i={host:o[4],port:o[5]||6800,secure:!(!o||!o[2]),secret:o[3]?o[3].split(":")[1]:"",path:o[6]||"/jsonrpc"};if(j[e.url])t[e.url]=j[e.url],delete j[e.url];else{var r=new I.Aria2(i);t[e.url]={aria2:r,rpc:e,push:e.push}}e.push&&a(t[e.url],e.name)});for(var e in j){var n=j[e].aria2;n&&n.socket&&1===n.socket.readyState&&j[e].aria2.close()}j=t}function a(t,e){var n=t.aria2;return!(!t.aria2||!t.aria2.socket||1!==n.socket.readyState)||(n.open().then(function(){s(t,e),t.reconnect&&(delete t.reconnect,R.success([o("Successful links to"),e]))}).catch(function(n){x()(safari,"application.activeBrowserWindow.activeTab.url")&&(!t.reconnect&&R.error([o("Make sure the aria2 is running, every 10 seconds will automatically retry")],[e,o("Connection fail")]),t.reconnect=!0),P=P||setInterval(function(){var t=0;S()(j,function(e){t+=a(e)?0:1}),t||clearInterval(P)},1e4)}),!1)}function r(){x()(safari,"extension.popovers[0].contentWindow.tlwin.refreshTaskList")&&safari.extension.popovers[0].contentWindow.tlwin.refreshTaskList()}function s(t,e){var n=t.aria2,i=function(t){r()},a=function(t){r()},s=function(t,e){r(),c(n,t.gid).then(function(t){R.show(e?"error":"success",[t,o("Download"),o(e?"error":"success")])})};n.onDownloadStart=i,n.onDownloadPause=a,n.onDownloadStop=a,n.onDownloadComplete=s,n.onBtDownloadComplete=s,n.onDownloadError=function(t){s(t,!0)}}function c(t,e){return t.tellStatus(e,["bittorrent"]).then(function(n){return t.getFiles(e).then(function(t){return{files:t,bt:n}})}).then(function(t){var e=t.files[0].path,n=e.split("/").pop();return t.bt&&t.bt.info?bt.bittorrent.info.name:n}).catch(function(t){R.error([o("Failed to get task information")])})}function l(t){var e=j[t[0].url],n=!!e&&e.aria2,i=D.enableCookie?"Cookie: "+t[3]:"";n&&t[1]?n.addUri([t[1]],{header:i,timeout:10,"content-disposition-default-utf8":!0,"user-agent":D.userAgent}).then(function(){R.success([o("Successfully added to the"),e.rpc.name,D.enableCookie?"":"(with cookie)"])}).catch(function(t){R.error([o("Fail to Added to the"),e.rpc.name,o("failure",{notfailback:!0}),D.enableCookie?"":"(without cookie)"]),console.log(t)}):R.error(["添加任务失败:没有url或者没有连接aria2"])}function u(t){"showOptions"===t.key&&f()}function f(){safari.application.activeBrowserWindow.openTab().url=safari.extension.baseURI+"options.html"}function d(){D=localStorage.getItem("safari2aria");try{D=JSON.parse(D||"{}")}catch(t){D={defaultRpcIndex:0}}L=D.filetypes?D.filetypes.split(" "):[];for(var t=0;t=0){var n=t.userInfo;n&&n.length&&n[0]||(t.target.disabled=!0)}}function g(t){n.i(C.a)(t.url,D,O)&&(t.preventDefault(),p("getCookie",function(e){l([E[D.defaultRpcIndex],t.url,t.target.url,e.cookie])}))}function w(t){E.forEach(function(e,n){t.contextMenu.appendContextMenuItem(["DownloadWithAria2",n].join("."),[o("Downloaded to"),e.name].join(""))}),D.enableXunleiLixian&&t.contextMenu.appendContextMenuItem("DownloadWithXunleilixian",[o("Import to thunder lixian")].join("")),D.enableBaiduLixian&&t.contextMenu.appendContextMenuItem("DownloadWithBaidulixian",[o("Import to baidu lixian")].join(""))}function y(t){M[t.name]&&M[t.name](t.message,t)}Object.defineProperty(e,"__esModule",{value:!0});var b=n(18),x=n.n(b),k=n(55),S=n.n(k),I=n(54),C=n(36),D={defaultRpcIndex:0},A={"zh-CN":{"Successful links to":"成功链接","Connection fail":"连接失败",Download:"下载",error:"失败","Import to thunder lixian":"导入至迅雷离线","Import to baidu lixian":"导入至百度离线","Downloaded to":"下载至",success:"成功","Successfully added to the":"成功添加至","Added to the":"添加至",failure:"失败","Failed to get task information":"获取任务信息失败","Make sure the aria2 is running, every 10 seconds will automatically retry":"请确认aria2已经运行,每隔10秒将会自动重试"}},O=void 0,L=[],E=[],j={},W={},P=void 0,M={updateSafari2Aria:function(t){localStorage.setItem("safari2aria",JSON.stringify(t)),d()},keyPress:function(t){h(t)},getConfig:function(){p("updateConfig",D)},documentReady:function(){S()(W,function(t){t.action()})},downloadFromIframe:function(t,e){l([E[D.defaultRpcIndex],t.url,e.target.url,t.cookie])}},R={success:function(t,e){R.show("success",t,e)},error:function(t,e){R.show("error",t,e)},show:function(t,e,n){e instanceof Array&&(e=e.join("")),n instanceof Array&&(n=n.join("")),p("showMassage",{action:t||"success",text:e,title:n})}};window.s2a={changeServer:function(t){var e=void 0;S()(E,function(n,o){n.url===t&&(e=o)}),D.defaultRpcIndex=e,y({name:"updateSafari2Aria",message:D})},dispatchMessage:y,openOptions:f,getConfig:function(){return{config:D,aria2Connects:j}}},document.addEventListener("DOMContentLoaded",d),safari.application.addEventListener("message",y,!1),safari.extension.settings.addEventListener("change",u,!1),safari.application.addEventListener("command",m,!1),safari.application.addEventListener("validate",v,!1),safari.application.addEventListener("beforeNavigate",g,!1),safari.application.addEventListener("contextmenu",w,!1)},36:function(t,e,n){"use strict";function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t&&!n[82]&&e.enableTypefiles?!n.isCommandPressed:n.isCommandPressed){if(t.match(/magnet:[^\\"]+/))return!0;var o=t.substr(t.lastIndexOf(".")+1);o=o.toLowerCase();for(var i=e.filetypes?e.filetypes.split(" "):[],a=0;a0&&(o.params=t.params);var i="http"+(this.secure?"s":"")+"://"+this.host+":"+this.port+this.path;fetch(i,{method:"POST",body:JSON.stringify(o),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(t){return t.json()}).then(function(t){n._onmessage(t)}).catch(e)},a.prototype.send=function(t){var e=Array.prototype.slice.call(arguments,1),n="function"==typeof e[e.length-1]?e.pop():null;return this.exec(t,e,n)},a.prototype.exec=function(t,e,n){if("string"!=typeof t)throw new TypeError(t+" is not a string");0!==t.indexOf("system.")&&0!==t.indexOf("aria2.")&&(t="aria2."+t);var i={method:t,"json-rpc":"2.0",id:this.lastId++},a=this.secret?["token:"+this.secret]:[];Array.isArray(e)&&("system.multicall"===t?(Array.isArray(e[0])&&e[0].forEach(function(t){t.params||(t.params=[]),t.params=a.concat(t.params)}),a=e):a=a.concat(e)),a.length>0&&(i.params=a),this.onsend(i);var r=this;return this.socket&&1===this.socket.readyState?this.socket.send(JSON.stringify(i)):this.http(i,function(t){r.callbacks[i.id](t),delete r.callbacks[i.id]}),o()(function(t){r.callbacks[i.id]=t},n)},a.prototype._onmessage=function(t){if(this.onmessage(t),void 0!==t.id){var e=this.callbacks[t.id];e&&(t.error?e(t.error):e(null,t.result),delete this.callbacks[t.id])}else if(t.method){var n=t.method.split("aria2.")[1];0===n.indexOf("on")&&"function"==typeof this[n]&&a.notifications.indexOf(n)>-1&&this[n].apply(this,t.params)}},a.prototype.open=function(t){var e="ws"+(this.secure?"s":"")+"://"+this.host+":"+this.port+this.path,n=this.socket=new WebSocket(e),i=this,a=!1;return n.onmessage=function(t){i._onmessage(JSON.parse(t.data))},o()(function(t){n.onopen=function(){a||(t(),a=!0),i.onopen()},n.onclose=function(e){i.onclose(),1006==e.code&&(a||(t(e),a=!0))},n.onerror=function(e){a||(t(e),a=!0)}},t)},a.prototype.close=function(t){var e=this.socket;return o()(function(t){e?(e.addEventListener("close",function(){t()}),e.close()):t()},t)},a.methods=["addUri","addTorrent","addMetalink","remove","forceRemove","pause","pauseAll","forcePause","forcePauseAll","unpause","unpauseAll","tellStatus","getUris","getFiles","getPeers","getServers","tellActive","tellWaiting","tellStopped","changePosition","changeUri","getOption","changeOption","getGlobalOption","changeGlobalOption","getGlobalStat","purgeDownloadResult","removeDownloadResult","getVersion","getSessionInfo","shutdown","forceShutdown","saveSession","system.multicall","system.listMethods","system.listNotifications"],a.notifications=["onDownloadStart","onDownloadPause","onDownloadStop","onDownloadComplete","onDownloadError","onBtDownloadComplete"],a.events=["onopen","onclose","onsend","onmessage"],a.options={secure:!1,host:"localhost",port:6800,secret:"",path:"/jsonrpc"},a.methods.forEach(function(t){var e=t.indexOf(".")>-1?t.split(".")[1]:t;a.prototype[e]=function(){return this.send.apply(this,[t].concat(Array.prototype.slice.call(arguments)))}}),a.notifications.forEach(function(t){a.prototype[t]=function(){}}),a.events.forEach(function(t){a.prototype[t]=function(){}}),n?t.exports=a:e.Aria2=a}(this)}).call(e,n(132)(t))}},[159]); \ No newline at end of file diff --git a/safari2aria.safariextension/static/js/global.2200b9fc6a37aab2770a.js b/safari2aria.safariextension/static/js/global.2200b9fc6a37aab2770a.js deleted file mode 100644 index c16fd87..0000000 --- a/safari2aria.safariextension/static/js/global.2200b9fc6a37aab2770a.js +++ /dev/null @@ -1 +0,0 @@ -webpackJsonp([4],{159:function(t,e,n){"use strict";function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=C.language||navigator.language;return x()(A,[n,t],e.notfailback?"":[t," "].join(""))}function i(){var t={};C.rpcList.forEach(function(e,n){var o=e.url.match(/^(http|ws)(s)?(?:\:\/\/)(token\:[^@]*)?@?([^\:\/]*)\:?(\d*)(\/[^\/]*)/),i={host:o[4],port:o[5]||6800,secure:!(!o||!o[2]),secret:o[3]?o[3].split(":")[1]:"",path:o[6]||"/jsonrpc"};if(j[e.url])t[e.url]=j[e.url],delete j[e.url];else{var r=new I.Aria2(i);t[e.url]={aria2:r,rpc:e,push:e.push}}e.push&&a(t[e.url],e.name)});for(var e in j){var n=j[e].aria2;n&&n.socket&&1===n.socket.readyState&&j[e].aria2.close()}j=t}function a(t,e){var n=t.aria2;return!(!t.aria2||!t.aria2.socket||1!==n.socket.readyState)||(n.open().then(function(){s(t,e),t.reconnect&&(delete t.reconnect,R.success([o("Successful links to"),e]))}).catch(function(n){x()(safari,"application.activeBrowserWindow.activeTab.url")&&(!t.reconnect&&R.error([o("Make sure the aria2 is running, every 10 seconds will automatically retry")],[e,o("Connection fail")]),t.reconnect=!0),P=P||setInterval(function(){var t=0;S()(j,function(e){t+=a(e)?0:1}),t||clearInterval(P)},1e4)}),!1)}function r(){x()(safari,"extension.popovers[0].contentWindow.tlwin.refreshTaskList")&&safari.extension.popovers[0].contentWindow.tlwin.refreshTaskList()}function s(t,e){var n=t.aria2,i=function(t){r()},a=function(t){r()},s=function(t,e){r(),c(n,t.gid).then(function(t){R.show(e?"error":"success",[t,o("Download"),o(e?"error":"success")])})};n.onDownloadStart=i,n.onDownloadPause=a,n.onDownloadStop=a,n.onDownloadComplete=s,n.onBtDownloadComplete=s,n.onDownloadError=function(t){s(t,!0)}}function c(t,e){return t.tellStatus(e,["bittorrent"]).then(function(n){return t.getFiles(e).then(function(t){return{files:t,bt:n}})}).then(function(t){var e=t.files[0].path,n=e.split("/").pop();return t.bt&&t.bt.info?bt.bittorrent.info.name:n}).catch(function(t){R.error([o("Failed to get task information")])})}function l(t){var e=j[t[0].url],n=!!e&&e.aria2,i=C.enableCookie?"Cookie: "+t[3]:"";n&&t[1]?n.addUri([t[1]],{header:i,timeout:10,"content-disposition-default-utf8":!0,"user-agent":C.userAgent}).then(function(){R.success([o("Successfully added to the"),e.rpc.name,C.enableCookie?"":"(with cookie)"])}).catch(function(t){R.error([o("Fail to Added to the"),e.rpc.name,o("failure",{notfailback:!0}),C.enableCookie?"":"(without cookie)"]),console.log(t)}):R.error(["添加任务失败:没有url或者没有连接aria2"])}function u(t){"showOptions"===t.key&&f()}function f(){safari.application.activeBrowserWindow.openTab().url=safari.extension.baseURI+"options.html"}function d(){C=localStorage.getItem("safari2aria");try{C=JSON.parse(C||"{}")}catch(t){C={defaultRpcIndex:0}}L=C.filetypes?C.filetypes.split(" "):[];for(var t=0;t=0){var n=t.userInfo;n&&n.length&&n[0]||(t.target.disabled=!0)}}function g(t){n.i(D.a)(t.url,C,O)&&(t.preventDefault(),p("getCookie",function(e){l([E[C.defaultRpcIndex],t.url,t.target.url,e.cookie])}))}function w(t){E.forEach(function(e,n){t.contextMenu.appendContextMenuItem(["DownloadWithAria2",n].join("."),[o("Downloaded to"),e.name].join(""))}),C.enableXunleiLixian&&t.contextMenu.appendContextMenuItem("DownloadWithXunleilixian",[o("Import to thunder lixian")].join("")),C.enableBaiduLixian&&t.contextMenu.appendContextMenuItem("DownloadWithBaidulixian",[o("Import to baidu lixian")].join(""))}function y(t){M[t.name]&&M[t.name](t.message,t)}Object.defineProperty(e,"__esModule",{value:!0});var b=n(18),x=n.n(b),k=n(55),S=n.n(k),I=n(54),D=n(36),C={defaultRpcIndex:0},A={"zh-CN":{"Successful links to":"成功链接","Connection fail":"连接失败",Download:"下载",error:"失败","Import to thunder lixian":"导入至迅雷离线","Import to baidu lixian":"导入至百度离线","Downloaded to":"下载至",success:"成功","Successfully added to the":"成功添加至","Added to the":"添加至",failure:"失败","Failed to get task information":"获取任务信息失败","Make sure the aria2 is running, every 10 seconds will automatically retry":"请确认aria2已经运行,每隔10秒将会自动重试"}},O=void 0,L=[],E=[],j={},W={},P=void 0,M={updateSafari2Aria:function(t){localStorage.setItem("safari2aria",JSON.stringify(t)),d()},keyPress:function(t){h(t)},getConfig:function(){p("sendToEndScript",C)},documentReady:function(){S()(W,function(t){t.action()})},downloadFromIframe:function(t,e){l([E[C.defaultRpcIndex],t.url,e.target.url,t.cookie])}},R={success:function(t,e){R.show("success",t,e)},error:function(t,e){R.show("error",t,e)},show:function(t,e,n){e instanceof Array&&(e=e.join("")),n instanceof Array&&(n=n.join("")),p("showMassage",{action:t||"success",text:e,title:n})}};window.s2a={changeServer:function(t){var e=void 0;S()(E,function(n,o){n.url===t&&(e=o)}),C.defaultRpcIndex=e,y({name:"updateSafari2Aria",message:C})},dispatchMessage:y,openOptions:f,getConfig:function(){return{config:C,aria2Connects:j}}},document.addEventListener("DOMContentLoaded",d),safari.application.addEventListener("message",y,!1),safari.extension.settings.addEventListener("change",u,!1),safari.application.addEventListener("command",m,!1),safari.application.addEventListener("validate",v,!1),safari.application.addEventListener("beforeNavigate",g,!1),safari.application.addEventListener("contextmenu",w,!1)},36:function(t,e,n){"use strict";function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t&&!n[82]&&e.enableTypefiles?!n.isCommandPressed:n.isCommandPressed){if(t.match(/magnet:[^\\"]+/))return!0;var o=t.substr(t.lastIndexOf(".")+1);o=o.toLowerCase();for(var i=e.filetypes?e.filetypes.split(" "):[],a=0;a0&&(o.params=t.params);var i="http"+(this.secure?"s":"")+"://"+this.host+":"+this.port+this.path;fetch(i,{method:"POST",body:JSON.stringify(o),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(t){return t.json()}).then(function(t){n._onmessage(t)}).catch(e)},a.prototype.send=function(t){var e=Array.prototype.slice.call(arguments,1),n="function"==typeof e[e.length-1]?e.pop():null;return this.exec(t,e,n)},a.prototype.exec=function(t,e,n){if("string"!=typeof t)throw new TypeError(t+" is not a string");0!==t.indexOf("system.")&&0!==t.indexOf("aria2.")&&(t="aria2."+t);var i={method:t,"json-rpc":"2.0",id:this.lastId++},a=this.secret?["token:"+this.secret]:[];Array.isArray(e)&&("system.multicall"===t?(Array.isArray(e[0])&&e[0].forEach(function(t){t.params||(t.params=[]),t.params=a.concat(t.params)}),a=e):a=a.concat(e)),a.length>0&&(i.params=a),this.onsend(i);var r=this;return this.socket&&1===this.socket.readyState?this.socket.send(JSON.stringify(i)):this.http(i,function(t){r.callbacks[i.id](t),delete r.callbacks[i.id]}),o()(function(t){r.callbacks[i.id]=t},n)},a.prototype._onmessage=function(t){if(this.onmessage(t),void 0!==t.id){var e=this.callbacks[t.id];e&&(t.error?e(t.error):e(null,t.result),delete this.callbacks[t.id])}else if(t.method){var n=t.method.split("aria2.")[1];0===n.indexOf("on")&&"function"==typeof this[n]&&a.notifications.indexOf(n)>-1&&this[n].apply(this,t.params)}},a.prototype.open=function(t){var e="ws"+(this.secure?"s":"")+"://"+this.host+":"+this.port+this.path,n=this.socket=new WebSocket(e),i=this,a=!1;return n.onmessage=function(t){i._onmessage(JSON.parse(t.data))},o()(function(t){n.onopen=function(){a||(t(),a=!0),i.onopen()},n.onclose=function(e){i.onclose(),1006==e.code&&(a||(t(e),a=!0))},n.onerror=function(e){a||(t(e),a=!0)}},t)},a.prototype.close=function(t){var e=this.socket;return o()(function(t){e?(e.addEventListener("close",function(){t()}),e.close()):t()},t)},a.methods=["addUri","addTorrent","addMetalink","remove","forceRemove","pause","pauseAll","forcePause","forcePauseAll","unpause","unpauseAll","tellStatus","getUris","getFiles","getPeers","getServers","tellActive","tellWaiting","tellStopped","changePosition","changeUri","getOption","changeOption","getGlobalOption","changeGlobalOption","getGlobalStat","purgeDownloadResult","removeDownloadResult","getVersion","getSessionInfo","shutdown","forceShutdown","saveSession","system.multicall","system.listMethods","system.listNotifications"],a.notifications=["onDownloadStart","onDownloadPause","onDownloadStop","onDownloadComplete","onDownloadError","onBtDownloadComplete"],a.events=["onopen","onclose","onsend","onmessage"],a.options={secure:!1,host:"localhost",port:6800,secret:"",path:"/jsonrpc"},a.methods.forEach(function(t){var e=t.indexOf(".")>-1?t.split(".")[1]:t;a.prototype[e]=function(){return this.send.apply(this,[t].concat(Array.prototype.slice.call(arguments)))}}),a.notifications.forEach(function(t){a.prototype[t]=function(){}}),a.events.forEach(function(t){a.prototype[t]=function(){}}),n?t.exports=a:e.Aria2=a}(this)}).call(e,n(132)(t))}},[159]); \ No newline at end of file diff --git a/safari2aria.safariextension/static/js/manifest.js b/safari2aria.safariextension/static/js/manifest.js index 3612cf3..6c7e683 100644 --- a/safari2aria.safariextension/static/js/manifest.js +++ b/safari2aria.safariextension/static/js/manifest.js @@ -1 +1 @@ -!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var i,u,f,d=0,s=[];d0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(e,n){setTimeout(function(){n("timeout to get config")},1e4),window.extensionMessageListener||safari.self.addEventListener("message",function(i){var t=0;window.extensionMessageListener.forEach(function(n){i.name===n.name&&(n.cb&&n.cb(i.message||{}),e(i.message||{}),t++)}),t||n("no listener"),i.message&&i.message.hasCb&&safari.self.tab.dispatchMessage([i.name,"cb"].join("_"),{cookie:document.cookie})},!1),window.extensionMessageListener=[].concat(window.extensionMessageListener||[]).concat(i.listeners||[]),i.send&&i.send.forEach(function(i){safari.self.tab.dispatchMessage(i.name,i.params)})})}}},[158]); \ No newline at end of file +webpackJsonp([5],{158:function(i,n,t){"use strict";function o(){var i=window.mDisableBaiduLimit;window.mDisableBaiduLimit=!0;var n="浏览器window.navigator属性修改失败,自动尝试方案2。",t="无法修改浏览器window.navigator,这将影响屏蔽功能。",o=window.navigator.platform,e=window.navigator.userAgent;try{Object.defineProperty(window.navigator,"platform",{get:function(){return window.mDisableBaiduLimit?"Android":o}}),Object.defineProperty(window.navigator,"userAgent",{get:function(){return window.mDisableBaiduLimit?"Android":e}})}catch(i){}!function(){if("Android"!==window.navigator.platform){console.log(n);try{window.navigator.__defineGetter__("platform",function(){return window.mDisableBaiduLimit?"Android":o}),window.navigator.__defineGetter__("userAgent",function(){return window.mDisableBaiduLimit?"Android":e})}catch(i){}"Android"!==window.navigator.platform&&console.log(t)}window.mDisableBaiduLimit=i}()}Object.defineProperty(n,"__esModule",{value:!0});var e=t(37);window.top===window&&location.href.match(/baidu/)&&t.i(e.a)(o)},37:function(i,n,t){"use strict";n.a=function(i,n){var t=document.createElement("script");t.type="text/javascript",t.innerHTML=["(",i.toString(),")(",JSON.stringify(n),")"].join(""),document.documentElement.appendChild(t)}}},[158]); \ No newline at end of file diff --git a/safari2aria.safariextz b/safari2aria.safariextz index b72ffa3..89ced7c 100644 Binary files a/safari2aria.safariextz and b/safari2aria.safariextz differ diff --git a/src/js/endscript/index.js b/src/js/endscript/index.js index 4427d30..08340de 100644 --- a/src/js/endscript/index.js +++ b/src/js/endscript/index.js @@ -2,6 +2,8 @@ import toastr from 'mini-toastr' import bdlx from './baiduLixian' import downloadAble from '@/public/downloadAble' import messageListener from '@/public/pageScriptMessage' +import runJs from '@/public/runInPage' + if (window.top === window) { (function () { @@ -44,9 +46,17 @@ if (window.top === window) { } return result } + function setExtWinConfig (config) { + console.log('disableBaiduLimit:',config.disableBaiduLimit); + window.mDisableBaiduLimit = config.disableBaiduLimit; + } + function handleMessage (e) { messageListener({ + send:[{ + name:'getConfig' + }], listeners:[ { name:"changeRpc", @@ -75,13 +85,18 @@ if (window.top === window) { } }, { - name:"sendToEndScript", + name:"updateConfig", + background:true, cb:function (message) { config = message; catchIframe(); safari.self.tab.dispatchMessage("documentReady", { cookie: document.cookie }); + //百度网盘取消限制 + location.href.match(/baidu/) && runJs(setExtWinConfig,{ + disableBaiduLimit:config.disableBaiduLimit + }); } } ] diff --git a/src/js/startscript/index.js b/src/js/startscript/index.js index 8219fa7..362d36e 100644 --- a/src/js/startscript/index.js +++ b/src/js/startscript/index.js @@ -1,8 +1,6 @@ /** * Created by liukai on 2017/6/21. */ -import messagesAction from '@/public/pageScriptMessage' - import run from '@/public/runInPage' function disableBaiduLimit () { @@ -47,30 +45,7 @@ function disableBaiduLimit () { } } -function getExtConfig (config) { - console.log('disableBaiduLimit:',config.disableBaiduLimit); - window.mDisableBaiduLimit = config.disableBaiduLimit; -} - - if (window.top === window && location.href.match(/baidu/)) { run(disableBaiduLimit); - messagesAction({ - send:[{ - name:'getConfig', - params:'' - }], - listeners:[ - { - name:'sendToEndScript', - cb:function (config) { - //console.log('getConfig:',config); - run(getExtConfig,{ - disableBaiduLimit:config.disableBaiduLimit - }); - } - } - ] - }) } diff --git a/src/pages/global/index.js b/src/pages/global/index.js index 09a58df..7db1e3e 100644 --- a/src/pages/global/index.js +++ b/src/pages/global/index.js @@ -42,9 +42,8 @@ let messageAction = { }, //配置更新后推送至页面脚本(主要用于开关iframe拦截) getConfig: function () { - sendMsg('sendToEndScript', config); + sendMsg('updateConfig', config); }, - //配置更新后推送至页面脚本(主要用于开关iframe拦截) documentReady: function () { _.forEach(endPageReadyAction,function (obj) { obj.action(); @@ -296,7 +295,7 @@ function restoreOptions () { for (let a = 0; a < fileTypes.length; a++)fileTypes[a] = fileTypes[a].toLowerCase() rpcList = config.rpcList; //更新配置后需要同步至页面脚本 - sendMsg('sendToEndScript', config); + sendMsg('updateConfig', config); initAria2(); if(_.get(safari,'extension.popovers[0].contentWindow.tlwin.refreshServerList')){ safari.extension.popovers[0].contentWindow.tlwin.refreshServerList(); diff --git a/src/public/pageScriptMessage.js b/src/public/pageScriptMessage.js index b2fa75e..7e1de18 100644 --- a/src/public/pageScriptMessage.js +++ b/src/public/pageScriptMessage.js @@ -13,13 +13,15 @@ export default function (config={}) { let count=0; window.extensionMessageListener.forEach(function (listener) { if(e.name === listener.name){ - listener.cb&&listener.cb(e.message || {}); - resolve(e.message || {}); - count++; + if(!document.hidden || listener.background){ + listener.cb&&listener.cb(e.message || {}); + resolve(e.message || {}); + count++; + } } }); if(!count){ - reject('no listener') + reject(document.hidden?'in background':'no listener') } if (e.message && e.message.hasCb) { safari.self.tab.dispatchMessage([e.name, 'cb'].join('_'), {