├── .browserslistrc ├── release ├── 115.crx ├── chrome.zip ├── img │ ├── icon.jpg │ ├── logo16.png │ ├── logo48.png │ ├── logo128.png │ └── logo.svg ├── _locales │ ├── zh_CN │ │ └── messages.json │ └── en │ │ └── messages.json ├── js │ ├── start.js │ ├── 115.js │ └── home.js ├── manifest.json ├── background.js └── css │ └── style.css ├── src ├── img │ ├── icon.jpg │ ├── logo128.png │ ├── logo16.png │ ├── logo48.png │ └── logo.svg ├── css │ ├── lib │ │ └── share.scss │ ├── text.scss │ ├── export.scss │ ├── modal.scss │ └── setting.scss └── js │ ├── start.js │ ├── lib │ ├── EventEmitter.js │ ├── downloader.js │ ├── store.js │ ├── secret.js │ ├── core.js │ └── ui.js │ ├── 115.js │ └── home.js ├── .stylelintrc.json ├── _locales ├── zh_CN │ └── messages.json └── en │ └── messages.json ├── .gitignore ├── .eslintrc.yml ├── .github ├── dependabot.yml └── workflows │ ├── ci.yml │ ├── build.yml │ └── release.yml ├── manifest.json ├── PRIVACY.md ├── README.md ├── package.json ├── background.js ├── gulpfile.esm.js └── LICENSE /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | -------------------------------------------------------------------------------- /release/115.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/release/115.crx -------------------------------------------------------------------------------- /src/img/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/src/img/icon.jpg -------------------------------------------------------------------------------- /release/chrome.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/release/chrome.zip -------------------------------------------------------------------------------- /release/img/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/release/img/icon.jpg -------------------------------------------------------------------------------- /src/img/logo128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/src/img/logo128.png -------------------------------------------------------------------------------- /src/img/logo16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/src/img/logo16.png -------------------------------------------------------------------------------- /src/img/logo48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/src/img/logo48.png -------------------------------------------------------------------------------- /release/img/logo16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/release/img/logo16.png -------------------------------------------------------------------------------- /release/img/logo48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/release/img/logo48.png -------------------------------------------------------------------------------- /release/img/logo128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgotaku/115/HEAD/release/img/logo128.png -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-sass-guidelines", 3 | "rules": { 4 | "max-nesting-depth": 4 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /_locales/zh_CN/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": { 3 | "message": "115下载助手" 4 | }, 5 | "description": { 6 | "message": "可以方便的把115网盘的下载地址导出到aria2-rpc,支持YAAW。" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /release/_locales/zh_CN/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": { 3 | "message": "115下载助手" 4 | }, 5 | "description": { 6 | "message": "可以方便的把115网盘的下载地址导出到aria2-rpc,支持YAAW。" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | 4 | # Editor directories and files 5 | .vscode/* 6 | !.vscode/extensions.json 7 | .idea 8 | .DS_Store 9 | *.suo 10 | *.ntvs* 11 | *.njsproj 12 | *.sln 13 | *.sw? 14 | -------------------------------------------------------------------------------- /_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": { 3 | "message": "115Exporter" 4 | }, 5 | "description": { 6 | "message": "Assistant for 115 to export download links to aria2-rpc." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | es2021: true 4 | extends: 5 | - standard 6 | globals: 7 | chrome: true 8 | parserOptions: 9 | ecmaVersion: latest 10 | sourceType: module 11 | rules: {} 12 | -------------------------------------------------------------------------------- /release/_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": { 3 | "message": "115Exporter" 4 | }, 5 | "description": { 6 | "message": "Assistant for 115 to export download links to aria2-rpc." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "20:00" 8 | open-pull-requests-limit: 10 9 | ignore: 10 | - dependency-name: gulp-imagemin 11 | - dependency-name: imagemin-mozjpeg 12 | -------------------------------------------------------------------------------- /src/css/lib/share.scss: -------------------------------------------------------------------------------- 1 | @charset 'utf-8'; 2 | $grey-da: #dadada; 3 | $grey-fa: #fafafa; 4 | $opacity-5: rgba(0, 0, 0, 0.5); 5 | $header-height: 40px; 6 | $row-height: 40px; 7 | $padding-space: 10px; 8 | $border: 1px solid $grey-da; 9 | 10 | @mixin button-border { 11 | border: 1px solid rgba(0, 0, 0, 0.15); 12 | border-radius: 4px; 13 | } 14 | -------------------------------------------------------------------------------- /release/js/start.js: -------------------------------------------------------------------------------- 1 | !function(){"use strict";const e=document.querySelector('iframe[rel="wangpan"]');e&&e.addEventListener("load",(function t(){if(e.contentDocument.querySelector("#js_top_panel_box")){const n=document.createElement("script");n.src=chrome.runtime.getURL("js/115.js"),document.body.appendChild(n),chrome.runtime.sendMessage({method:"addScript",data:"js/home.js"}),e.removeEventListener("load",t)}}))}(); -------------------------------------------------------------------------------- /src/js/start.js: -------------------------------------------------------------------------------- 1 | const iframe = document.querySelector('iframe[rel="wangpan"]') 2 | function add115JS () { 3 | if (iframe.contentDocument.querySelector('#js_top_panel_box')) { 4 | const script = document.createElement('script') 5 | script.src = chrome.runtime.getURL('js/115.js') 6 | document.body.appendChild(script) 7 | chrome.runtime.sendMessage({ 8 | method: 'addScript', 9 | data: 'js/home.js' 10 | }) 11 | iframe.removeEventListener('load', add115JS) 12 | } 13 | } 14 | 15 | if (iframe) { 16 | iframe.addEventListener('load', add115JS) 17 | } 18 | -------------------------------------------------------------------------------- /src/js/lib/EventEmitter.js: -------------------------------------------------------------------------------- 1 | class EventEmitter { 2 | constructor () { 3 | this._listeners = {} 4 | } 5 | 6 | /** 7 | * @param {string} name - event name 8 | * @param {function(data: *): void} fn - listener function 9 | */ 10 | on (name, fn) { 11 | const list = this._listeners[name] = this._listeners[name] || [] 12 | list.push(fn) 13 | } 14 | 15 | /** 16 | * @param {string} name - event name 17 | * @param {*} data - data to emit event listeners 18 | */ 19 | trigger (name, data) { 20 | const fns = this._listeners[name] || [] 21 | fns.forEach(fn => fn(data)) 22 | } 23 | 24 | /** 25 | * @param {string} name - event name 26 | */ 27 | off (name) { 28 | delete this._listeners[name] 29 | } 30 | } 31 | 32 | export default EventEmitter 33 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "background": { 3 | "service_worker": "background.js" 4 | }, 5 | "content_scripts": [ 6 | { 7 | "js": ["js/start.js"], 8 | "matches": ["*://*.115.com/*"], 9 | "run_at": "document_end" 10 | }, 11 | { 12 | "css": ["css/style.css"], 13 | "all_frames": true, 14 | "matches": ["*://*.115.com/*"] 15 | } 16 | ], 17 | "default_locale": "en", 18 | "description": "__MSG_description__", 19 | "icons": { 20 | "16": "img/logo16.png", 21 | "48": "img/logo48.png", 22 | "128": "img/logo128.png" 23 | }, 24 | "web_accessible_resources": [{ 25 | "resources": ["js/115.js"], 26 | "matches": ["*://*.115.com/*"] 27 | }], 28 | "manifest_version": 3, 29 | "permissions": ["cookies", "storage", "notifications", "scripting"], 30 | "host_permissions": ["*://*.115.com/*"], 31 | "name": "__MSG_appName__", 32 | "version": "0.5.1" 33 | } 34 | -------------------------------------------------------------------------------- /release/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "background": { 3 | "service_worker": "background.js" 4 | }, 5 | "content_scripts": [ 6 | { 7 | "js": ["js/start.js"], 8 | "matches": ["*://*.115.com/*"], 9 | "run_at": "document_end" 10 | }, 11 | { 12 | "css": ["css/style.css"], 13 | "all_frames": true, 14 | "matches": ["*://*.115.com/*"] 15 | } 16 | ], 17 | "default_locale": "en", 18 | "description": "__MSG_description__", 19 | "icons": { 20 | "16": "img/logo16.png", 21 | "48": "img/logo48.png", 22 | "128": "img/logo128.png" 23 | }, 24 | "web_accessible_resources": [{ 25 | "resources": ["js/115.js"], 26 | "matches": ["*://*.115.com/*"] 27 | }], 28 | "manifest_version": 3, 29 | "permissions": ["cookies", "storage", "notifications", "scripting"], 30 | "host_permissions": ["*://*.115.com/*"], 31 | "name": "__MSG_appName__", 32 | "version": "0.5.1" 33 | } 34 | -------------------------------------------------------------------------------- /src/css/text.scss: -------------------------------------------------------------------------------- 1 | @charset 'utf-8'; 2 | @import './lib/share'; 3 | 4 | .text-menu { 5 | &-row { 6 | box-sizing: border-box; 7 | display: flex; 8 | justify-content: space-between; 9 | padding: 10px 0 5px; 10 | 11 | &:last-child { 12 | height: 200px; 13 | padding-bottom: 10px; 14 | } 15 | } 16 | 17 | &-button { 18 | @include button-border; 19 | color: #666; 20 | height: 38px; 21 | line-height: 38px; 22 | padding: 0 30px; 23 | text-align: center; 24 | 25 | &:hover, 26 | &:focus { 27 | border-color: #5cb3fd; 28 | color: #666; 29 | text-decoration: none; 30 | } 31 | } 32 | 33 | &-textarea { 34 | @include button-border; 35 | padding: 5px $padding-space; 36 | resize: none; 37 | width: 100%; 38 | } 39 | } 40 | 41 | // stylelint-disable selector-no-qualifying-type 42 | input[type=file] { 43 | visibility: hidden; 44 | } 45 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.event.number || github.sha }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | test: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v3 20 | with: 21 | fetch-depth: 0 22 | 23 | - name: Install pnpm 24 | uses: pnpm/action-setup@v2 25 | with: 26 | version: 6 27 | 28 | - name: Set node version 29 | uses: actions/setup-node@v3 30 | with: 31 | node-version: '16.x' 32 | cache: 'pnpm' 33 | 34 | - name: Install deps 35 | run: pnpm install --frozen-lockfile 36 | 37 | - name: Lint test 38 | run: pnpm lint:fix 39 | 40 | - name: Build 115 41 | run: pnpm build 42 | -------------------------------------------------------------------------------- /src/css/export.scss: -------------------------------------------------------------------------------- 1 | @charset 'utf-8'; 2 | @import './lib/share'; 3 | 4 | .export { 5 | cursor: pointer; 6 | font-size: 14px; 7 | line-height: 32px; 8 | position: absolute; 9 | right: 180px; 10 | text-align: center; 11 | top: 20px; 12 | width: 82px; 13 | z-index: 1111; 14 | 15 | &.open-o { 16 | .export-button { 17 | border-bottom-left-radius: 0; 18 | border-bottom-right-radius: 0; 19 | } 20 | 21 | .export-menu { 22 | display: flex; 23 | } 24 | } 25 | 26 | &-button { 27 | background: #00a8ff; 28 | border-radius: 4px; 29 | color: #fff; 30 | display: block; 31 | } 32 | 33 | &-menu { 34 | background: #fff; 35 | border-radius: 0 0 3px 3px; 36 | box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); 37 | display: none; 38 | flex-direction: column; 39 | position: absolute; 40 | width: 100%; 41 | 42 | &-item:hover { 43 | background: $grey-da; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/css/modal.scss: -------------------------------------------------------------------------------- 1 | @charset 'utf-8'; 2 | @import './lib/share'; 3 | 4 | .modal { 5 | align-items: center; 6 | background-color: $opacity-5; 7 | display: none; 8 | height: 100%; 9 | justify-content: center; 10 | margin: auto; 11 | position: fixed; 12 | top: 0; 13 | width: 100%; 14 | z-index: 99; 15 | 16 | &.open-o { 17 | display: flex; 18 | } 19 | 20 | &-inner { 21 | background-color: $grey-fa; 22 | border-radius: 4px; 23 | margin: auto; 24 | width: 650px; 25 | } 26 | 27 | &-header { 28 | border-bottom: $border; 29 | display: flex; 30 | height: $header-height; 31 | line-height: $header-height; 32 | } 33 | 34 | &-title { 35 | flex: 1; 36 | font-weight: bold; 37 | padding-left: $padding-space; 38 | } 39 | 40 | &-close { 41 | cursor: pointer; 42 | font-size: 30px; 43 | padding: 0 $padding-space; 44 | } 45 | 46 | &-body { 47 | padding: 0 $padding-space; 48 | } 49 | 50 | &-footer { 51 | border-top: $border; 52 | display: flex; 53 | padding-bottom: $padding-space; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /release/js/115.js: -------------------------------------------------------------------------------- 1 | !function(){"use strict";(new class{constructor(){this.context=document.querySelector('iframe[rel="wangpan"]').contentDocument}showToast({message:e,type:t}){window.Core.MinMessage.Show({text:e,type:t,timeout:1e3})}startListen(){window.addEventListener("message",(e=>{e.data.type&&"getSelected"===e.data.type&&window.postMessage({type:"selected",data:this.getSelected()},location.origin),e.data.type&&"getHovered"===e.data.type&&window.postMessage({type:"hovered",data:this.getHovered()},location.origin),e.data.type&&"showToast"===e.data.type&&this.showToast(e.data.data),e.data.type&&"refresh"===e.data.type&&this.refresh()}))}refresh(){this.context=document.querySelector('iframe[rel="wangpan"]').contentDocument}getFileInfoFromElements(e){const t=[];return Array.from(e).forEach((e=>{const o=e.getAttribute("file_type");"1"===o&&t.push({isdir:!1,sha1:e.getAttribute("sha1"),pick_code:e.getAttribute("pick_code"),path:""}),"0"===o&&t.push({isdir:!0,cate_id:e.getAttribute("cate_id"),path:""})})),t}getSelected(){const e=this.context.querySelectorAll('li[rel="item"].selected');return this.getFileInfoFromElements(e)}getHovered(){const e=this.context.querySelectorAll('li[rel="item"].hover');return this.getFileInfoFromElements(e)}}).startListen()}(); -------------------------------------------------------------------------------- /PRIVACY.md: -------------------------------------------------------------------------------- 1 | # 115Exporter 2 | 3 | > Last updated: 2 October 2022 4 | 5 | This page informs you of our policies regarding the collection, use, and disclosure of personal data when using the 115Exporter extension and the choices you have associated with that data. 6 | 7 | We use your data to provide and improve the service. By using the service, you agree to the collection and use of information in accordance with this policy. 8 | 9 | ## Summary 10 | 11 | - **We do not track extension usage at all.** 12 | 13 | - **We never send information or extension settings outside of your browser.** 14 | 15 | - **By default, the extension only interacts with the 115.com website.** 16 | 17 | ## Data Storage 18 | 19 | We store some data locally on your device permanently. This information is still available even if your browser is restarted. 20 | 21 | This data can only be accessed by the 115Exporter extension on your browser. 22 | 23 | Stored information might include: 24 | 25 | - Extension settings (such as download path). 26 | 27 | The extension by itself does not send any of this information outside of your device. 28 | 29 | However, if you enable Chrome Sync, Firefox Sync, Edge Sync, or any other compatible browser data synchronization feature, this information might be sent to that service by your browser. 30 | 31 | ## Data Collection 32 | 33 | No data is collected by this extension or sent to any remote server. 34 | 35 | ## Contact 36 | 37 | If you have any questions, please [open an issue](https://github.com/acgotaku/115/issues/new). 38 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [workflow_dispatch] 4 | 5 | concurrency: 6 | group: ${{ github.workflow }}-${{ github.event.number || github.sha }} 7 | cancel-in-progress: true 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | with: 15 | fetch-depth: 0 16 | 17 | - name: Install pnpm 18 | uses: pnpm/action-setup@v2 19 | with: 20 | version: 6 21 | 22 | - name: Set node version 23 | uses: actions/setup-node@v3 24 | with: 25 | node-version: '16.x' 26 | cache: 'pnpm' 27 | 28 | - name: Install RX3-Creator 29 | run: | 30 | sudo add-apt-repository universe 31 | sudo apt update 32 | sudo apt install -y python2 vim-common 33 | curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py 34 | sudo python2 get-pip.py 35 | git clone https://github.com/pawliczka/CRX3-Creator.git /tmp/CRX3-Creator 36 | sudo pip2 install -r /tmp/CRX3-Creator/requirements.txt 37 | 38 | - name: Install deps 39 | run: pnpm install --frozen-lockfile 40 | 41 | - name: Build 115 42 | run: pnpm build 43 | 44 | - name: Write pem to file 45 | run: | 46 | echo "$CHROME_PEM" > /tmp/chrome.pem 47 | env: 48 | CHROME_PEM: ${{ secrets.CHROME_PEM }} 49 | 50 | - name: Package 115 51 | run: | 52 | python /tmp/CRX3-Creator/main.py -o 115.crx -pem /tmp/chrome.pem dist 53 | rm -rf release 54 | mv dist release 55 | mv 115.crx release 56 | 57 | - uses: EndBug/add-and-commit@v9 58 | with: 59 | add: "release" 60 | message: "[ci skip] update crx and release" 61 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v[0-9]+.[0-9]+.[0-9]*' 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.event.number || github.sha }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | release: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | with: 18 | fetch-depth: 0 19 | 20 | - name: Install pnpm 21 | uses: pnpm/action-setup@v2 22 | with: 23 | version: 6 24 | 25 | - name: Set node version 26 | uses: actions/setup-node@v3 27 | with: 28 | node-version: '16.x' 29 | cache: 'pnpm' 30 | 31 | # - name: Install RX3-Creator 32 | # run: | 33 | # sudo add-apt-repository universe 34 | # sudo apt update 35 | # sudo apt install -y python2 vim-common 36 | # curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py 37 | # sudo python2 get-pip.py 38 | # git clone https://github.com/pawliczka/CRX3-Creator.git /tmp/CRX3-Creator 39 | # sudo pip2 install -r /tmp/CRX3-Creator/requirements.txt 40 | 41 | # - name: Install deps 42 | # run: pnpm install --frozen-lockfile 43 | 44 | # - name: Build 115 45 | # run: pnpm build 46 | 47 | # - name: Write pem to file 48 | # run: | 49 | # echo "$CHROME_PEM" > /tmp/chrome.pem 50 | # env: 51 | # CHROME_PEM: ${{ secrets.CHROME_PEM }} 52 | 53 | # - name: Package 115 54 | # run: | 55 | # python /tmp/CRX3-Creator/main.py -o 115-${{ github.ref_name }}.crx -pem /tmp/chrome.pem dist 56 | 57 | - name: Create release 58 | uses: ncipollo/release-action@v1 59 | with: 60 | # artifacts: 115-${{ github.ref_name }}.crx 61 | tag: ${{ github.ref_name }} 62 | name: Release ${{ github.ref_name }} 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 115Exporter [![Chrome Web Store](https://img.shields.io/chrome-web-store/v/ojafklbojgenkohhdgdjeaepnbjffdjf.svg)](https://chrome.google.com/webstore/detail/115exporter/ojafklbojgenkohhdgdjeaepnbjffdjf?hl=en) 2 | 3 | ## Sign in on Chrome 4 | 5 | Use fake115 can Sign in on Chrome: https://github.com/kkHAIKE/fake115 6 | 7 | ## Usage 8 | 9 | - Please click save button when change config. 10 | - Recommended Settings: 11 | - Set `--rpc-secret=` if you are using aria2 1.18.4(or higher) with 'JSON-RPC PATH' like http://token:secret@hostname:port/jsonrpc 12 | - Set `--rpc-user= --rpc-passwd=` if you are using aria2 1.15.2(or higher) with 'JSON-RPC PATH' like http://username:passwd@hostname:port/jsonrpc 13 | - Use `http://localhost:6800/jsonrpc#max-connection-per-server=5&split=10` set download options for specific file. 14 | 15 | ## Install 16 | 17 | * Chrome : Click **Settings** -> **Extensions**, drag `115.crx` file to the page, install it, or check **Developer mode** -> **Load unpacked extension**, navigate to the `release` folder. 18 | * Firefox : Open **about:debugging** in Firefox, click "Load Temporary Add-on" and navigate to the `release` folder, select `manifest.json`, click OK. 19 | 20 | ## License 21 | 22 | ![GPLv3](https://www.gnu.org/graphics/gplv3-127x51.png) 23 | 24 | 115Exporter is licensed under [GNU General Public License](https://www.gnu.org/licenses/gpl.html) Version 3 or later. 25 | 26 | 115Exporter is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by 27 | the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 28 | 29 | 115Exporter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 30 | 31 | You should have received a copy of the GNU General Public License along with 115Exporter. If not, see . 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "115", 3 | "version": "0.5.1", 4 | "description": "Assistant for 115 to export download links to aria2-rpc.", 5 | "main": "background.js", 6 | "scripts": { 7 | "start": "npm run dev", 8 | "serve": "npm run dev", 9 | "dev": "cross-env NODE_ENV=development gulp serve", 10 | "build": "cross-env NODE_ENV=production gulp publish", 11 | "clean": "gulp clean", 12 | "eslint:fix": "eslint --fix src background.js", 13 | "stylelint:fix": "stylelint \"src/**/*.scss\" --fix", 14 | "lint:fix": "npm run stylelint:fix && npm run eslint:fix" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/acgotaku/115.git" 19 | }, 20 | "keywords": [ 21 | "115", 22 | "aria2c" 23 | ], 24 | "author": "acgotaku311", 25 | "license": "GPL-3.0", 26 | "bugs": { 27 | "url": "https://github.com/acgotaku/115/issues" 28 | }, 29 | "homepage": "https://github.com/acgotaku/115#readme", 30 | "devDependencies": { 31 | "@rollup/plugin-commonjs": "^22.0.0", 32 | "@rollup/plugin-node-resolve": "^13.3.0", 33 | "autoprefixer": "^10.4.7", 34 | "cross-env": "^7.0.3", 35 | "del": "^6.0.0", 36 | "eslint": "^8.16.0", 37 | "eslint-config-standard": "^17.0.0", 38 | "eslint-plugin-import": "^2.26.0", 39 | "eslint-plugin-n": "^15.2.0", 40 | "eslint-plugin-promise": "^6.0.0", 41 | "esm": "^3.2.25", 42 | "gulp": "^4.0.2", 43 | "gulp-clean-css": "^4.3.0", 44 | "gulp-concat": "^2.6.1", 45 | "gulp-if": "^3.0.0", 46 | "gulp-imagemin": "^7.1.0", 47 | "gulp-plumber": "^1.2.1", 48 | "gulp-postcss": "^9.0.1", 49 | "gulp-rollup-each": "^4.0.1", 50 | "gulp-sass": "^5.1.0", 51 | "gulp-terser": "^2.0.1", 52 | "gulp-zip": "^5.1.0", 53 | "imagemin-mozjpeg": "^9.0.0", 54 | "imagemin-pngquant": "^9.0.2", 55 | "postcss": "^8.4.14", 56 | "rollup": "^2.74.1", 57 | "sass": "^1.52.1", 58 | "stylelint": "^14.8.3", 59 | "stylelint-config-sass-guidelines": "^9.0.1", 60 | "stylelint-order": "^5.0.0", 61 | "stylelint-scss": "^4.2.0" 62 | }, 63 | "dependencies": { 64 | "big-integer": "^1.6.51", 65 | "blueimp-md5": "^2.18.0" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/js/115.js: -------------------------------------------------------------------------------- 1 | class Disk { 2 | constructor () { 3 | this.context = document.querySelector('iframe[rel="wangpan"]').contentDocument 4 | } 5 | 6 | // Type类型有 7 | // inf err war 8 | showToast ({ message, type }) { 9 | window.Core.MinMessage.Show({ 10 | text: message, 11 | type, 12 | timeout: 1000 13 | }) 14 | } 15 | 16 | startListen () { 17 | window.addEventListener('message', (event) => { 18 | if (event.data.type && event.data.type === 'getSelected') { 19 | window.postMessage({ type: 'selected', data: this.getSelected() }, location.origin) 20 | } 21 | if (event.data.type && event.data.type === 'getHovered') { 22 | window.postMessage({ type: 'hovered', data: this.getHovered() }, location.origin) 23 | } 24 | if (event.data.type && event.data.type === 'showToast') { 25 | this.showToast(event.data.data) 26 | } 27 | if (event.data.type && event.data.type === 'refresh') { 28 | this.refresh() 29 | } 30 | }) 31 | } 32 | 33 | refresh () { 34 | this.context = document.querySelector('iframe[rel="wangpan"]').contentDocument 35 | } 36 | 37 | getFileInfoFromElements (list) { 38 | const selected = [] 39 | Array.from(list).forEach((item) => { 40 | const type = item.getAttribute('file_type') 41 | // file 42 | if (type === '1') { 43 | selected.push({ 44 | isdir: false, 45 | sha1: item.getAttribute('sha1'), 46 | pick_code: item.getAttribute('pick_code'), 47 | path: '' 48 | }) 49 | } 50 | // fold 51 | if (type === '0') { 52 | selected.push({ 53 | isdir: true, 54 | cate_id: item.getAttribute('cate_id'), 55 | path: '' 56 | }) 57 | } 58 | }) 59 | return selected 60 | } 61 | 62 | getSelected () { 63 | const list = this.context.querySelectorAll('li[rel="item"].selected') 64 | return this.getFileInfoFromElements(list) 65 | } 66 | 67 | getHovered () { 68 | const list = this.context.querySelectorAll('li[rel="item"].hover') 69 | return this.getFileInfoFromElements(list) 70 | } 71 | } 72 | 73 | const disk = new Disk() 74 | 75 | disk.startListen() 76 | -------------------------------------------------------------------------------- /src/js/lib/downloader.js: -------------------------------------------------------------------------------- 1 | import Core from './core' 2 | 3 | class Downloader { 4 | constructor (listParameter) { 5 | this.listParameter = listParameter 6 | this.fileDownloadInfo = [] 7 | this.currentTaskId = 0 8 | this.completedCount = 0 9 | this.folders = [] 10 | this.files = {} 11 | } 12 | 13 | start (interval = 300, done) { 14 | this.interval = interval 15 | this.done = done 16 | this.currentTaskId = new Date().getTime() 17 | this.getNextFile(this.currentTaskId) 18 | } 19 | 20 | reset () { 21 | this.fileDownloadInfo = [] 22 | this.currentTaskId = 0 23 | this.folders = [] 24 | this.files = {} 25 | this.completedCount = 0 26 | } 27 | 28 | addFolder (item) { 29 | this.folders.push(item) 30 | } 31 | 32 | addFile (file) { 33 | this.files[file.pick_code] = file 34 | } 35 | 36 | getNextFile (taskId) { 37 | if (taskId !== this.currentTaskId) { 38 | return 39 | } 40 | if (this.folders.length !== 0) { 41 | this.completedCount++ 42 | Core.showToast(`正在获取文件列表... ${this.completedCount}/${this.completedCount + this.folders.length - 1}`, 'inf') 43 | const fold = this.folders.pop() 44 | this.listParameter.search.cid = fold.cate_id 45 | Core.sendToBackground('fetch', { 46 | url: `${this.listParameter.url}${Core.objectToQueryString(this.listParameter.search)}`, 47 | options: this.listParameter.options 48 | }, (data) => { 49 | setTimeout(() => this.getNextFile(taskId), this.interval) 50 | const path = fold.path + data.path[data.path.length - 1].name + '/' 51 | data.data.forEach((item) => { 52 | if (!item.sha) { 53 | this.folders.push({ 54 | cate_id: item.cid, 55 | path 56 | }) 57 | } else { 58 | this.files[item.pc] = { 59 | path, 60 | isdir: false, 61 | sha1: item.sha, 62 | pick_code: item.pc 63 | } 64 | } 65 | }) 66 | }) 67 | } else if (this.files.length !== 0) { 68 | Core.showToast('正在获取下载地址...', 'inf') 69 | this.getFiles(this.files).then(() => { 70 | this.done(this.fileDownloadInfo) 71 | }) 72 | } else { 73 | Core.showToast('一个文件都没有哦...', 'war') 74 | this.reset() 75 | } 76 | } 77 | 78 | getFiles (files) { 79 | throw new Error('subclass should implement this method!') 80 | } 81 | } 82 | 83 | export default Downloader 84 | -------------------------------------------------------------------------------- /src/js/lib/store.js: -------------------------------------------------------------------------------- 1 | import EventEmitter from './EventEmitter' 2 | 3 | class Store extends EventEmitter { 4 | constructor () { 5 | super() 6 | this.defaultRPC = [{ name: 'ARIA2 RPC', url: 'http://localhost:6800/jsonrpc' }] 7 | this.defaultUserAgent = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 115Browser/5.1.3' 8 | this.defaultReferer = 'https://115.com/' 9 | this.defaultConfigData = { 10 | rpcList: this.defaultRPC, 11 | configSync: false, 12 | sha1Check: false, 13 | vip: true, 14 | small: false, 15 | interval: 300, 16 | downloadPath: '', 17 | userAgent: this.defaultUserAgent, 18 | browserUserAgent: true, 19 | referer: this.defaultReferer, 20 | headers: '' 21 | } 22 | this.configData = {} 23 | this.on('initConfigData', this.init.bind(this)) 24 | this.on('setConfigData', this.set.bind(this)) 25 | this.on('clearConfigData', this.clear.bind(this)) 26 | } 27 | 28 | init () { 29 | chrome.storage.sync.get(null, (items) => { 30 | for (const key in items) { 31 | chrome.storage.local.set({ key: items[key] }, () => { 32 | console.log('chrome first local set: %s, %s', key, items[key]) 33 | }) 34 | } 35 | }) 36 | chrome.storage.local.get(null, (items) => { 37 | this.configData = Object.assign({}, this.defaultConfigData, items) 38 | this.trigger('updateView', this.configData) 39 | }) 40 | } 41 | 42 | getConfigData (key = null) { 43 | if (key) { 44 | return this.configData[key] 45 | } else { 46 | return this.configData 47 | } 48 | } 49 | 50 | set (configData) { 51 | this.configData = configData 52 | this.save(configData) 53 | this.trigger('updateView', configData) 54 | } 55 | 56 | save (configData) { 57 | for (const key in configData) { 58 | chrome.storage.local.set({ [key]: configData[key] }, () => { 59 | console.log('chrome local set: %s, %s', key, configData[key]) 60 | }) 61 | if (configData.configSync === true) { 62 | chrome.storage.sync.set({ [key]: configData[key] }, () => { 63 | console.log('chrome sync set: %s, %s', key, configData[key]) 64 | }) 65 | } 66 | } 67 | } 68 | 69 | clear () { 70 | chrome.storage.sync.clear() 71 | chrome.storage.local.clear() 72 | this.configData = this.defaultConfigData 73 | this.trigger('updateView', this.configData) 74 | } 75 | } 76 | 77 | export default new Store() 78 | -------------------------------------------------------------------------------- /src/css/setting.scss: -------------------------------------------------------------------------------- 1 | @charset 'utf-8'; 2 | @import './lib/share'; 3 | 4 | .setting-menu { 5 | &-message { 6 | align-items: center; 7 | display: flex; 8 | height: 20px; 9 | } 10 | 11 | &-row { 12 | box-sizing: border-box; 13 | display: flex; 14 | height: $row-height; 15 | padding: 5px 0; 16 | 17 | &:last-child { 18 | height: 100px; 19 | } 20 | } 21 | 22 | &-row:hover { 23 | background-color: #eff4f8; 24 | } 25 | 26 | &-input { 27 | @include button-border; 28 | height: 28px; 29 | padding: 0 $padding-space; 30 | width: 70%; 31 | 32 | &.small-o { 33 | width: 30%; 34 | } 35 | 36 | &.textarea-o { 37 | height: 80px; 38 | padding: 5px $padding-space; 39 | } 40 | 41 | &:focus { 42 | border-color: #5cb3fd; 43 | } 44 | 45 | &:disabled { 46 | opacity: 0.5; 47 | 48 | &:hover { 49 | cursor: not-allowed; 50 | } 51 | } 52 | } 53 | 54 | &-button { 55 | @include button-border; 56 | color: #666; 57 | height: 28px; 58 | line-height: 28px; 59 | margin-left: 10px; 60 | padding: 0 $padding-space; 61 | text-align: center; 62 | 63 | &:hover, 64 | &:focus { 65 | border-color: #5cb3fd; 66 | color: #666; 67 | text-decoration: none; 68 | } 69 | 70 | &.large-o { 71 | height: 40px; 72 | line-height: 40px; 73 | width: 120px; 74 | } 75 | 76 | &.blue-o { 77 | background-color: #3b8cff; 78 | color: #fff; 79 | 80 | &:hover { 81 | background-color: #77afff; 82 | } 83 | } 84 | } 85 | 86 | .version-s { 87 | margin-left: auto; 88 | margin-right: 10px; 89 | } 90 | 91 | &-checkbox { 92 | cursor: pointer; 93 | } 94 | 95 | &-label { 96 | padding-left: $padding-space; 97 | 98 | &.orange-o { 99 | color: #e15f00; 100 | } 101 | 102 | &.for { 103 | &-checkbox { 104 | font-size: 12px; 105 | padding-left: 5px; 106 | } 107 | } 108 | } 109 | 110 | &-name { 111 | align-items: center; 112 | display: flex; 113 | width: 20%; 114 | } 115 | 116 | &-value { 117 | align-items: center; 118 | display: flex; 119 | padding-left: 20px; 120 | width: 80%; 121 | } 122 | 123 | &-copyright, 124 | &-operate { 125 | width: 50%; 126 | } 127 | 128 | &-item { 129 | align-items: center; 130 | display: flex; 131 | height: $row-height; 132 | } 133 | 134 | &-link { 135 | padding-left: $padding-space; 136 | } 137 | 138 | &-operate { 139 | align-items: flex-end; 140 | display: flex; 141 | padding: $padding-space; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /release/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | const httpSend = ({ url, options }, resolve, reject) => { 2 | fetch(url, options).then((response) => { 3 | if (response.ok) { 4 | response.json().then((data) => { 5 | resolve(data) 6 | }) 7 | } else { 8 | reject(response) 9 | } 10 | }).catch((err) => { 11 | reject(err) 12 | }) 13 | } 14 | // https://developer.chrome.com/apps/runtime#event-onMessage 15 | chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { 16 | switch (request.method) { 17 | case 'addScript': 18 | chrome.scripting.executeScript({ 19 | target: { tabId: sender.tab.id }, 20 | files: [request.data] 21 | }) 22 | break 23 | case 'rpcData': 24 | httpSend(request.data, () => { 25 | sendResponse(true) 26 | }, (err) => { 27 | console.log(err) 28 | sendResponse(false) 29 | }) 30 | return true 31 | case 'configData': 32 | for (const key in request.data) { 33 | localStorage.setItem(key, request.data[key]) 34 | } 35 | break 36 | case 'rpcVersion': 37 | httpSend(request.data, (data) => { 38 | sendResponse(data.result.version) 39 | }, (err) => { 40 | console.log(err) 41 | sendResponse(false) 42 | }) 43 | return true 44 | case 'fetch': 45 | httpSend(request.data, (data) => { 46 | sendResponse(data) 47 | }, (err) => { 48 | console.log(err) 49 | sendResponse(err) 50 | }) 51 | return true 52 | case 'getCookies': 53 | getCookies(request.data).then(value => sendResponse(value)) 54 | return true 55 | } 56 | }) 57 | 58 | // Promise style `chrome.cookies.get()` 59 | const getCookie = (detail) => { 60 | return new Promise(function (resolve) { 61 | chrome.cookies.getAll(detail, resolve) 62 | }) 63 | } 64 | 65 | const getCookies = (details) => { 66 | return new Promise(function (resolve) { 67 | const list = details.map(item => getCookie(item)) 68 | Promise.all(list).then(function (cookies) { 69 | const obj = {} 70 | for (const cookie of cookies) { 71 | for (const item of cookie) { 72 | if (item !== null) { 73 | obj[item.name] = item.value 74 | } 75 | } 76 | } 77 | resolve(obj) 78 | }) 79 | }) 80 | } 81 | 82 | const showNotification = (id, opt) => { 83 | chrome.notifications.create(id, opt, () => {}) 84 | setTimeout(() => { 85 | chrome.notifications.clear(id, () => {}) 86 | }, 5000) 87 | } 88 | // 软件版本更新提示 89 | (async () => { 90 | const manifest = chrome.runtime.getManifest() 91 | const { version: previousVersion } = await chrome.storage.local.get('version') 92 | if (previousVersion === '' || previousVersion !== manifest.version) { 93 | const opt = { 94 | type: 'basic', 95 | title: '更新', 96 | message: '115助手更新到' + manifest.version + '版本啦~\n此次更新修复导出下载~', 97 | iconUrl: 'img/icon.jpg' 98 | } 99 | const id = new Date().getTime().toString() 100 | showNotification(id, opt) 101 | await chrome.storage.local.set({ 102 | version: manifest.version 103 | }) 104 | } 105 | })() 106 | -------------------------------------------------------------------------------- /release/background.js: -------------------------------------------------------------------------------- 1 | const httpSend = ({ url, options }, resolve, reject) => { 2 | fetch(url, options).then((response) => { 3 | if (response.ok) { 4 | response.json().then((data) => { 5 | resolve(data) 6 | }) 7 | } else { 8 | reject(response) 9 | } 10 | }).catch((err) => { 11 | reject(err) 12 | }) 13 | } 14 | // https://developer.chrome.com/apps/runtime#event-onMessage 15 | chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { 16 | switch (request.method) { 17 | case 'addScript': 18 | chrome.scripting.executeScript({ 19 | target: { tabId: sender.tab.id }, 20 | files: [request.data] 21 | }) 22 | break 23 | case 'rpcData': 24 | httpSend(request.data, () => { 25 | sendResponse(true) 26 | }, (err) => { 27 | console.log(err) 28 | sendResponse(false) 29 | }) 30 | return true 31 | case 'configData': 32 | for (const key in request.data) { 33 | localStorage.setItem(key, request.data[key]) 34 | } 35 | break 36 | case 'rpcVersion': 37 | httpSend(request.data, (data) => { 38 | sendResponse(data.result.version) 39 | }, (err) => { 40 | console.log(err) 41 | sendResponse(false) 42 | }) 43 | return true 44 | case 'fetch': 45 | httpSend(request.data, (data) => { 46 | sendResponse(data) 47 | }, (err) => { 48 | console.log(err) 49 | sendResponse(err) 50 | }) 51 | return true 52 | case 'getCookies': 53 | getCookies(request.data).then(value => sendResponse(value)) 54 | return true 55 | } 56 | }) 57 | 58 | // Promise style `chrome.cookies.get()` 59 | const getCookie = (detail) => { 60 | return new Promise(function (resolve) { 61 | chrome.cookies.getAll(detail, resolve) 62 | }) 63 | } 64 | 65 | const getCookies = (details) => { 66 | return new Promise(function (resolve) { 67 | const list = details.map(item => getCookie(item)) 68 | Promise.all(list).then(function (cookies) { 69 | const obj = {} 70 | for (const cookie of cookies) { 71 | for (const item of cookie) { 72 | if (item !== null) { 73 | obj[item.name] = item.value 74 | } 75 | } 76 | } 77 | resolve(obj) 78 | }) 79 | }) 80 | } 81 | 82 | const showNotification = (id, opt) => { 83 | chrome.notifications.create(id, opt, () => {}) 84 | setTimeout(() => { 85 | chrome.notifications.clear(id, () => {}) 86 | }, 5000) 87 | } 88 | // 软件版本更新提示 89 | (async () => { 90 | const manifest = chrome.runtime.getManifest() 91 | const { version: previousVersion } = await chrome.storage.local.get('version') 92 | if (previousVersion === '' || previousVersion !== manifest.version) { 93 | const opt = { 94 | type: 'basic', 95 | title: '更新', 96 | message: '115助手更新到' + manifest.version + '版本啦~\n此次更新修复导出下载~', 97 | iconUrl: 'img/icon.jpg' 98 | } 99 | const id = new Date().getTime().toString() 100 | showNotification(id, opt) 101 | await chrome.storage.local.set({ 102 | version: manifest.version 103 | }) 104 | } 105 | })() 106 | -------------------------------------------------------------------------------- /src/img/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /gulpfile.esm.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp' 2 | 3 | import rollupEach from 'gulp-rollup-each' 4 | import rollupCommon from '@rollup/plugin-commonjs' 5 | import rollupResolve from '@rollup/plugin-node-resolve' 6 | 7 | import del from 'del' 8 | import gulpIf from 'gulp-if' 9 | 10 | import postcss from 'gulp-postcss' 11 | import dartSass from 'sass' 12 | import gulpSass from 'gulp-sass' 13 | import autoprefixer from 'autoprefixer' 14 | import concat from 'gulp-concat' 15 | import cleanCSS from 'gulp-clean-css' 16 | 17 | import imagemin from 'gulp-imagemin' 18 | import mozjpeg from 'imagemin-mozjpeg' 19 | import pngquant from 'imagemin-pngquant' 20 | 21 | import plumber from 'gulp-plumber' 22 | 23 | import terser from 'gulp-terser' 24 | 25 | import zip from 'gulp-zip' 26 | 27 | const sass = gulpSass(dartSass) 28 | 29 | const paths = { 30 | scripts: { 31 | src: 'src/js/**/*.js', 32 | entry: 'src/js/*.js', 33 | dest: 'dist/js/' 34 | }, 35 | styles: { 36 | src: 'src/css/**/*.scss', 37 | dest: 'dist/css/' 38 | }, 39 | images: { 40 | src: 'src/img/**/*', 41 | dest: 'dist/img/' 42 | }, 43 | copys: { 44 | src: ['_locales/**/*', 'background.js', 'manifest.json'], 45 | dest: 'dist/' 46 | }, 47 | vendor: { 48 | src: ['src/vendor/*.js'], 49 | dest: 'dist/js/' 50 | }, 51 | compress: { 52 | src: 'dist/**/*', 53 | dest: 'dist/' 54 | } 55 | } 56 | 57 | const config = { 58 | plumberConfig: { 59 | errorHandler: function (err) { 60 | console.log(err.toString()) 61 | this.emit('end') 62 | } 63 | }, 64 | env: { 65 | dev: process.env.NODE_ENV === 'development', 66 | prod: process.env.NODE_ENV === 'production' 67 | } 68 | } 69 | 70 | function scripts () { 71 | return gulp.src(paths.scripts.entry, { sourcemaps: config.env.dev }) 72 | .pipe(plumber(config.plumberConfig)) 73 | .pipe(rollupEach({ 74 | isCache: true, 75 | plugins: [ 76 | rollupCommon(), 77 | rollupResolve({ 78 | browser: true 79 | }) 80 | ] 81 | }, 82 | { 83 | format: 'iife' 84 | } 85 | )) 86 | .pipe(gulpIf(config.env.prod, terser())) 87 | .pipe(gulp.dest(paths.scripts.dest, { sourcemaps: config.env.dev })) 88 | } 89 | 90 | function styles () { 91 | return gulp.src(paths.styles.src) 92 | .pipe(plumber(config.plumberConfig)) 93 | .pipe(sass({ 94 | precision: 3, 95 | includePaths: ['.'] 96 | })) 97 | .pipe(postcss([ 98 | autoprefixer() 99 | ])) 100 | .pipe(concat('style.css')) 101 | .pipe(gulpIf(config.env.prod, cleanCSS())) 102 | .pipe(gulp.dest(paths.styles.dest), { sourcemaps: config.env.dev }) 103 | } 104 | 105 | function images () { 106 | return gulp.src(paths.images.src) 107 | .pipe(plumber(config.plumberConfig)) 108 | .pipe(imagemin([ 109 | pngquant(), 110 | mozjpeg(), 111 | imagemin.svgo()], { 112 | verbose: true 113 | })) 114 | .pipe(gulp.dest(paths.images.dest)) 115 | } 116 | 117 | function copys () { 118 | return gulp.src(paths.copys.src, { base: '.' }) 119 | .pipe(gulp.dest(paths.copys.dest)) 120 | } 121 | 122 | function copyVendor () { 123 | return gulp.src(paths.vendor.src) 124 | .pipe(gulp.dest(paths.vendor.dest)) 125 | } 126 | 127 | function clean () { 128 | return del(['dist']) 129 | } 130 | 131 | function watch () { 132 | gulp.watch(paths.copys.src, copys) 133 | gulp.watch(paths.scripts.src, scripts) 134 | gulp.watch(paths.styles.src, styles) 135 | } 136 | 137 | export function compress () { 138 | return gulp.src(paths.compress.src) 139 | .pipe(zip('chrome.zip')) 140 | .pipe(gulp.dest(paths.compress.dest)) 141 | } 142 | 143 | const build = gulp.parallel(scripts, styles, images, copys, copyVendor) 144 | const serve = gulp.series(clean, build, watch) 145 | const publish = gulp.series(clean, build, compress) 146 | 147 | exports.build = build 148 | exports.serve = serve 149 | exports.publish = publish 150 | exports.clean = clean 151 | -------------------------------------------------------------------------------- /release/css/style.css: -------------------------------------------------------------------------------- 1 | .export{cursor:pointer;font-size:14px;line-height:32px;position:absolute;right:180px;text-align:center;top:20px;width:82px;z-index:1111}.export.open-o .export-button{border-bottom-left-radius:0;border-bottom-right-radius:0}.export.open-o .export-menu{display:-webkit-box;display:-ms-flexbox;display:flex}.export-button{background:#00a8ff;border-radius:4px;color:#fff;display:block}.export-menu{background:#fff;border-radius:0 0 3px 3px;-webkit-box-shadow:0 2px 10px rgba(0,0,0,.3);box-shadow:0 2px 10px rgba(0,0,0,.3);display:none;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;position:absolute;width:100%}.export-menu-item:hover{background:#dadada}.modal{-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:rgba(0,0,0,.5);display:none;height:100%;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin:auto;position:fixed;top:0;width:100%;z-index:99}.modal.open-o{display:-webkit-box;display:-ms-flexbox;display:flex}.modal-inner{background-color:#fafafa;border-radius:4px;margin:auto;width:650px}.modal-header{border-bottom:1px solid #dadada;display:-webkit-box;display:-ms-flexbox;display:flex;height:40px;line-height:40px}.modal-title{-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:700;padding-left:10px}.modal-close{cursor:pointer;font-size:30px;padding:0 10px}.modal-body{padding:0 10px}.modal-footer{border-top:1px solid #dadada;display:-webkit-box;display:-ms-flexbox;display:flex;padding-bottom:10px}.setting-menu-message{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;height:20px}.setting-menu-row{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;height:40px;padding:5px 0}.setting-menu-row:last-child{height:100px}.setting-menu-row:hover{background-color:#eff4f8}.setting-menu-input{border:1px solid rgba(0,0,0,.15);border-radius:4px;height:28px;padding:0 10px;width:70%}.setting-menu-input.small-o{width:30%}.setting-menu-input.textarea-o{height:80px;padding:5px 10px}.setting-menu-input:focus{border-color:#5cb3fd}.setting-menu-input:disabled{opacity:.5}.setting-menu-input:disabled:hover{cursor:not-allowed}.setting-menu-button{border:1px solid rgba(0,0,0,.15);border-radius:4px;color:#666;height:28px;line-height:28px;margin-left:10px;padding:0 10px;text-align:center}.setting-menu-button:focus,.setting-menu-button:hover{border-color:#5cb3fd;color:#666;text-decoration:none}.setting-menu-button.large-o{height:40px;line-height:40px;width:120px}.setting-menu-button.blue-o{background-color:#3b8cff;color:#fff}.setting-menu-button.blue-o:hover{background-color:#77afff}.setting-menu .version-s{margin-left:auto;margin-right:10px}.setting-menu-checkbox{cursor:pointer}.setting-menu-label{padding-left:10px}.setting-menu-label.orange-o{color:#e15f00}.setting-menu-label.for-checkbox{font-size:12px;padding-left:5px}.setting-menu-name{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;width:20%}.setting-menu-value{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;padding-left:20px;width:80%}.setting-menu-copyright,.setting-menu-operate{width:50%}.setting-menu-item{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;height:40px}.setting-menu-link{padding-left:10px}.setting-menu-operate{-webkit-box-align:end;-ms-flex-align:end;align-items:flex-end;display:-webkit-box;display:-ms-flexbox;display:flex;padding:10px}.text-menu-row{-webkit-box-sizing:border-box;box-sizing:border-box;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;padding:10px 0 5px}.text-menu-row:last-child{height:200px;padding-bottom:10px}.text-menu-button{border:1px solid rgba(0,0,0,.15);border-radius:4px;color:#666;height:38px;line-height:38px;padding:0 30px;text-align:center}.text-menu-button:focus,.text-menu-button:hover{border-color:#5cb3fd;color:#666;text-decoration:none}.text-menu-textarea{border:1px solid rgba(0,0,0,.15);border-radius:4px;padding:5px 10px;resize:none;width:100%}input[type=file]{visibility:hidden} -------------------------------------------------------------------------------- /src/js/lib/secret.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable prefer-const */ 2 | import md5 from 'blueimp-md5' 3 | import bigInt from 'big-integer' 4 | 5 | class MyRsa { 6 | constructor () { 7 | this.n = bigInt('8686980c0f5a24c4b9d43020cd2c22703ff3f450756529058b1cf88f09b8602136477198a6e2683149659bd122c33592fdb5ad47944ad1ea4d36c6b172aad6338c3bb6ac6227502d010993ac967d1aef00f0c8e038de2e4d3bc2ec368af2e9f10a6f1eda4f7262f136420c07c331b871bf139f74f3010e3c4fe57df3afb71683', 16) 8 | this.e = bigInt('10001', 16) 9 | }; 10 | 11 | a2hex (byteArray) { 12 | let hexString = '' 13 | let nextHexByte 14 | for (let i = 0; i < byteArray.length; i++) { 15 | nextHexByte = byteArray[i].toString(16) 16 | if (nextHexByte.length < 2) { 17 | nextHexByte = '0' + nextHexByte 18 | } 19 | hexString += nextHexByte 20 | } 21 | return hexString 22 | } 23 | 24 | hex2a (hex) { 25 | let str = '' 26 | for (let i = 0; i < hex.length; i += 2) { 27 | str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)) 28 | } 29 | return str 30 | } 31 | 32 | pkcs1pad2 (s, n) { 33 | if (n < s.length + 11) { 34 | return null 35 | } 36 | let ba = [] 37 | let i = s.length - 1 38 | while (i >= 0 && n > 0) { 39 | ba[--n] = s.charCodeAt(i--) 40 | } 41 | ba[--n] = 0 42 | while (n > 2) { // random non-zero pad 43 | ba[--n] = 0xff 44 | } 45 | ba[--n] = 2 46 | ba[--n] = 0 47 | let c = this.a2hex(ba) 48 | return bigInt(c, 16) 49 | } 50 | 51 | pkcs1unpad2 (a) { 52 | let b = a.toString(16) 53 | if (b.length % 2 !== 0) { 54 | b = '0' + b 55 | } 56 | let c = this.hex2a(b) 57 | let i = 1 58 | while (c.charCodeAt(i) !== 0) { 59 | i++ 60 | } 61 | return c.slice(i + 1) 62 | } 63 | 64 | encrypt (text) { 65 | let m = this.pkcs1pad2(text, 0x80) 66 | let c = m.modPow(this.e, this.n) 67 | let h = c.toString(16) 68 | while (h.length < 0x80 * 2) { 69 | h = '0' + h 70 | } 71 | return h 72 | }; 73 | 74 | decrypt (text) { 75 | let ba = [] 76 | let i = 0 77 | while (i < text.length) { 78 | ba[i] = text.charCodeAt(i) 79 | i += 1 80 | } 81 | let a = bigInt(this.a2hex(ba), 16) 82 | let c = a.modPow(this.e, this.n) 83 | let d = this.pkcs1unpad2(c) 84 | return d 85 | }; 86 | } 87 | 88 | class Secret { 89 | constructor () { 90 | this.rsa = new MyRsa() 91 | 92 | this.kts = [240, 229, 105, 174, 191, 220, 191, 138, 26, 69, 232, 190, 125, 166, 115, 184, 222, 143, 231, 196, 69, 218, 134, 196, 155, 100, 139, 20, 106, 180, 241, 170, 56, 1, 53, 158, 38, 105, 44, 134, 0, 107, 79, 165, 54, 52, 98, 166, 42, 150, 104, 24, 242, 74, 253, 189, 107, 151, 143, 77, 143, 137, 19, 183, 108, 142, 147, 237, 14, 13, 72, 62, 215, 47, 136, 216, 254, 254, 126, 134, 80, 149, 79, 209, 235, 131, 38, 52, 219, 102, 123, 156, 126, 157, 122, 129, 50, 234, 182, 51, 222, 58, 169, 89, 52, 102, 59, 170, 186, 129, 96, 72, 185, 213, 129, 156, 248, 108, 132, 119, 255, 84, 120, 38, 95, 190, 232, 30, 54, 159, 52, 128, 92, 69, 44, 155, 118, 213, 27, 143, 204, 195, 184, 245] 93 | 94 | this.keyS = [0x29, 0x23, 0x21, 0x5E] 95 | 96 | this.keyL = [120, 6, 173, 76, 51, 134, 93, 24, 76, 1, 63, 70] 97 | } 98 | 99 | xor115Enc (src, srclen, key, keylen) { 100 | let i, j, k, mod4, ref, ref1, ref2, ret 101 | mod4 = srclen % 4 102 | ret = [] 103 | if (mod4 !== 0) { 104 | for (i = j = 0, ref = mod4; (ref >= 0 ? j < ref : j > ref); i = ref >= 0 ? ++j : --j) { 105 | ret.push(src[i] ^ key[i % keylen]) 106 | } 107 | } 108 | for (i = k = ref1 = mod4, ref2 = srclen; (ref1 <= ref2 ? k < ref2 : k > ref2); i = ref1 <= ref2 ? ++k : --k) { 109 | ret.push(src[i] ^ key[(i - mod4) % keylen]) 110 | } 111 | return ret 112 | }; 113 | 114 | getkey (length, key) { 115 | let i 116 | if (key != null) { 117 | return (() => { 118 | let j, ref, results 119 | results = [] 120 | for (i = j = 0, ref = length; (ref >= 0 ? j < ref : j > ref); i = ref >= 0 ? ++j : --j) { 121 | results.push(((key[i] + this.kts[length * i]) & 0xff) ^ this.kts[length * (length - 1 - i)]) 122 | } 123 | return results 124 | })() 125 | } 126 | if (length === 12) { 127 | return this.keyL.slice(0) 128 | } 129 | return this.keyS.slice(0) 130 | } 131 | 132 | asymEncode (src, srclen) { 133 | let i, j, m, ref, ret 134 | m = 128 - 11 135 | ret = '' 136 | for (i = j = 0, ref = Math.floor((srclen + m - 1) / m); (ref >= 0 ? j < ref : j > ref); i = ref >= 0 ? ++j : --j) { 137 | ret += this.rsa.encrypt(this.bytesToString(src.slice(i * m, Math.min((i + 1) * m, srclen)))) 138 | } 139 | return window.btoa(this.rsa.hex2a(ret)) 140 | } 141 | 142 | asymDecode (src, srclen) { 143 | let i, j, m, ref, ret 144 | m = 128 145 | ret = '' 146 | for (i = j = 0, ref = Math.floor((srclen + m - 1) / m); (ref >= 0 ? j < ref : j > ref); i = ref >= 0 ? ++j : --j) { 147 | ret += this.rsa.decrypt(this.bytesToString(src.slice(i * m, Math.min((i + 1) * m, srclen)))) 148 | } 149 | return this.stringToBytes(ret) 150 | }; 151 | 152 | symEncode (src, srclen, key1, key2) { 153 | let k1, k2, ret 154 | k1 = this.getkey(4, key1) 155 | k2 = this.getkey(12, key2) 156 | ret = this.xor115Enc(src, srclen, k1, 4) 157 | ret.reverse() 158 | ret = this.xor115Enc(ret, srclen, k2, 12) 159 | return ret 160 | }; 161 | 162 | symDecode (src, srclen, key1, key2) { 163 | let k1, k2, ret 164 | k1 = this.getkey(4, key1) 165 | k2 = this.getkey(12, key2) 166 | ret = this.xor115Enc(src, srclen, k2, 12) 167 | ret.reverse() 168 | ret = this.xor115Enc(ret, srclen, k1, 4) 169 | return ret 170 | }; 171 | 172 | bytesToString (buf) { 173 | let i, j, len, ret 174 | ret = '' 175 | for (j = 0, len = buf.length; j < len; j++) { 176 | i = buf[j] 177 | ret += String.fromCharCode(i) 178 | } 179 | return ret 180 | } 181 | 182 | stringToBytes (str) { 183 | let i, j, ref, ret 184 | ret = [] 185 | for (i = j = 0, ref = str.length; (ref >= 0 ? j < ref : j > ref); i = ref >= 0 ? ++j : --j) { 186 | ret.push(str.charCodeAt(i)) 187 | } 188 | return ret 189 | } 190 | 191 | encode (str, timestamp) { 192 | const key = this.stringToBytes(md5(`!@###@#${timestamp}DFDR@#@#`)) 193 | let temp = this.stringToBytes(str) 194 | temp = this.symEncode(temp, temp.length, key, null) 195 | temp = key.slice(0, 16).concat(temp) 196 | return { 197 | data: this.asymEncode(temp, temp.length), 198 | key 199 | } 200 | } 201 | 202 | decode (str, key) { 203 | let temp = this.stringToBytes(window.atob(str)) 204 | temp = this.asymDecode(temp, temp.length) 205 | return this.bytesToString(this.symDecode(temp.slice(16), temp.length - 16, key, temp.slice(0, 16))) 206 | } 207 | } 208 | 209 | export default new Secret() 210 | -------------------------------------------------------------------------------- /src/js/home.js: -------------------------------------------------------------------------------- 1 | import Core from './lib/core' 2 | import UI from './lib/ui' 3 | import Downloader from './lib/downloader' 4 | import Secret from './lib/secret' 5 | 6 | class Home extends Downloader { 7 | constructor () { 8 | const search = { 9 | aid: 1, 10 | limit: 1000, 11 | show_dir: 1, 12 | cid: '' 13 | } 14 | const listParameter = { 15 | search, 16 | url: `${location.protocol}//webapi.115.com/files?`, 17 | options: { 18 | credentials: 'include', 19 | method: 'GET' 20 | } 21 | } 22 | super(listParameter) 23 | this.mode = 'RPC' 24 | this.rpcURL = 'http://localhost:6800/jsonrpc' 25 | this.iframe = document.querySelector('iframe[rel="wangpan"]') 26 | } 27 | 28 | initialize () { 29 | this.context = document.querySelector('iframe[rel="wangpan"]').contentDocument 30 | UI.init() 31 | UI.addMenu(this.context.querySelector('#js_top_panel_box'), 'afterbegin') 32 | this.context.querySelector('.right-tvf').style.display = 'block' 33 | this.addMenuButtonEventListener() 34 | UI.addContextMenuRPCSectionWithCallback(() => { 35 | this.addContextMenuEventListener() 36 | }) 37 | Core.showToast('初始化成功!', 'inf') 38 | return this 39 | } 40 | 41 | startListen () { 42 | const exportFiles = (files) => { 43 | files.forEach((item) => { 44 | if (item.isdir) { 45 | this.addFolder(item) 46 | } else { 47 | this.addFile(item) 48 | } 49 | }) 50 | this.start(Core.getConfigData('interval'), (fileDownloadInfo) => { 51 | if (this.mode === 'RPC') { 52 | Core.aria2RPCMode(this.rpcURL, fileDownloadInfo) 53 | } 54 | if (this.mode === 'TXT') { 55 | Core.aria2TXTMode(fileDownloadInfo) 56 | document.querySelector('#textMenu').classList.add('open-o') 57 | } 58 | if (this.mode === 'OPEN') { 59 | for (const f of fileDownloadInfo) { 60 | window.open('https://115.com/?ct=play&ac=location&pickcode=' + f.pickcode) 61 | } 62 | } 63 | }) 64 | } 65 | 66 | window.addEventListener('message', (event) => { 67 | const type = event.data.type 68 | if (!type) { 69 | return 70 | } 71 | if (type === 'selected' || type === 'hovered') { 72 | this.reset() 73 | const selectedFile = event.data.data 74 | if (selectedFile.length === 0) { 75 | Core.showToast('请选择一下你要保存的文件哦', 'war') 76 | return 77 | } 78 | exportFiles(selectedFile) 79 | } 80 | }) 81 | this.iframe.addEventListener('load', () => { 82 | this.initialize() 83 | window.postMessage({ type: 'refresh' }, location.origin) 84 | }) 85 | } 86 | 87 | addMenuButtonEventListener () { 88 | const menuButton = this.context.querySelector('#aria2List') 89 | menuButton.addEventListener('click', (event) => { 90 | const rpcURL = event.target.dataset.url 91 | if (rpcURL) { 92 | this.rpcURL = rpcURL 93 | this.getSelected() 94 | this.mode = 'RPC' 95 | } 96 | if (event.target.id === 'aria2Text') { 97 | this.getSelected() 98 | this.mode = 'TXT' 99 | } 100 | if (event.target.id === 'batchOpen') { 101 | this.getSelected() 102 | this.mode = 'OPEN' 103 | } 104 | }) 105 | } 106 | 107 | addContextMenuEventListener () { 108 | const section = this.context.querySelector('#more-menu-rpc-section') 109 | section.addEventListener('click', (event) => { 110 | const rpcURL = event.target.dataset.url 111 | if (rpcURL) { 112 | this.rpcURL = rpcURL 113 | this.getHovered() 114 | this.mode = 'RPC' 115 | } 116 | }) 117 | } 118 | 119 | getSelected () { 120 | window.postMessage({ type: 'getSelected' }, location.origin) 121 | } 122 | 123 | getHovered () { 124 | window.postMessage({ type: 'getHovered' }, location.origin) 125 | } 126 | 127 | getFile (pickcode) { 128 | const vip = Core.getConfigData('vip') 129 | if (vip) { 130 | return this.getFileFromProAPI(pickcode) 131 | } else { 132 | return this.getFileFromWebAPI(pickcode) 133 | } 134 | } 135 | 136 | getFileFromWebAPI (pickcode) { 137 | const options = { 138 | credentials: 'include', 139 | method: 'GET' 140 | } 141 | return new Promise((resolve) => { 142 | Core.sendToBackground('fetch', { 143 | url: `${location.protocol}//webapi.115.com/files/download?pickcode=${pickcode}`, 144 | options 145 | }, (data) => { 146 | if (data.file_url) { 147 | const path = data.file_url.match(/.*115.com(\/.*\/)/)[1] 148 | Core.requestCookies([{ path }]).then((cookies) => { 149 | data.cookies = cookies 150 | resolve(data) 151 | }) 152 | } else { 153 | Core.showToast('无法获取下载地址!', 'err') 154 | resolve(pickcode) 155 | } 156 | }) 157 | }) 158 | } 159 | 160 | getFileFromProAPI (pickcode) { 161 | const now = Date.now() 162 | const timestamp = Math.floor(now / 1000) 163 | const { data, key } = Secret.encode(JSON.stringify({ 164 | pickcode 165 | }), timestamp) 166 | const options = { 167 | headers: { 168 | 'Content-Type': 'application/x-www-form-urlencoded' 169 | }, 170 | credentials: 'include', 171 | method: 'POST', 172 | body: `data=${encodeURIComponent(data)}` 173 | } 174 | return new Promise((resolve) => { 175 | Core.sendToBackground('fetch', { 176 | url: `https://proapi.115.com/app/chrome/downurl?t=${timestamp}`, 177 | options 178 | }, (json) => { 179 | if (json.state) { 180 | const result = JSON.parse(Secret.decode(json.data, key)) 181 | const data = Object.values(result).pop() 182 | data.pickcode = data.pick_code 183 | data.file_url = data.url.url 184 | if (data.file_url) { 185 | Core.requestCookies([{ url: 'https://proapi.115.com/', name: 'acw_tc' }]).then((cookies) => { 186 | data.cookies = cookies 187 | resolve(data) 188 | }) 189 | } else { 190 | Core.showToast('无法获取下载地址!', 'err') 191 | resolve(pickcode) 192 | } 193 | } else { 194 | resolve(pickcode) 195 | } 196 | }) 197 | }) 198 | } 199 | 200 | async getFiles (files) { 201 | for (const pickcode in files) { 202 | await this.sleep(Core.getConfigData('interval')) 203 | const file = await this.getFile(pickcode) 204 | if (this.isObject(file)) { 205 | this.fileDownloadInfo.push({ 206 | name: files[file.pickcode].path + file.file_name, 207 | link: file.file_url, 208 | size: file.file_size, 209 | sha1: files[file.pickcode].sha1, 210 | cookies: file.cookies, 211 | pickcode: file.pickcode 212 | }) 213 | } else { 214 | console.log(files[file]) 215 | } 216 | } 217 | } 218 | 219 | sleep (ms) { 220 | return new Promise(resolve => setTimeout(resolve, ms)) 221 | } 222 | 223 | isObject (obj) { 224 | return obj !== null && typeof obj === 'object' 225 | } 226 | } 227 | 228 | const home = new Home() 229 | 230 | home.initialize().startListen() 231 | -------------------------------------------------------------------------------- /src/js/lib/core.js: -------------------------------------------------------------------------------- 1 | import Store from './store' 2 | 3 | class Core { 4 | constructor () { 5 | this.cookies = {} 6 | } 7 | 8 | httpSend ({ url, options }, resolve, reject) { 9 | fetch(url, options).then((response) => { 10 | if (response.ok) { 11 | response.json().then((data) => { 12 | resolve(data) 13 | }) 14 | } else { 15 | reject(response) 16 | } 17 | }).catch((err) => { 18 | reject(err) 19 | }) 20 | } 21 | 22 | getConfigData (key = null) { 23 | return Store.getConfigData(key) 24 | } 25 | 26 | objectToQueryString (obj) { 27 | return Object.keys(obj).map((key) => { 28 | return `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}` 29 | }).join('&') 30 | } 31 | 32 | sendToBackground (method, data, callback) { 33 | chrome.runtime.sendMessage({ 34 | method, 35 | data 36 | }, callback) 37 | } 38 | 39 | showToast (message, type) { 40 | window.postMessage({ type: 'showToast', data: { message, type } }, location.origin) 41 | } 42 | 43 | getHashParameter (name) { 44 | const hash = window.location.hash 45 | const paramsString = hash.substr(1) 46 | const searchParams = new URLSearchParams(paramsString) 47 | return searchParams.get(name) 48 | } 49 | 50 | formatCookies () { 51 | const cookies = [] 52 | for (const key in this.cookies) { 53 | cookies.push(`${key}=${this.cookies[key]}`) 54 | } 55 | return cookies.join('; ') 56 | } 57 | 58 | getHeader (type = 'RPC') { 59 | const headerOption = [] 60 | const useBrowserUA = this.getConfigData('browserUserAgent') 61 | let userAgent = this.getConfigData('userAgent') 62 | if (useBrowserUA) { 63 | const browserUA = navigator.userAgent 64 | if (browserUA && browserUA.length) { 65 | userAgent = browserUA 66 | } 67 | } 68 | headerOption.push(`User-Agent: ${userAgent}`) 69 | headerOption.push(`Referer: ${this.getConfigData('referer')}`) 70 | headerOption.push(`Cookie: ${this.formatCookies()}`) 71 | const headers = this.getConfigData('headers') 72 | if (headers) { 73 | headers.split('\n').forEach((item) => { 74 | headerOption.push(item) 75 | }) 76 | } 77 | if (type === 'RPC') { 78 | return headerOption 79 | } else if (type === 'aria2Cmd') { 80 | return headerOption.map(item => `--header ${JSON.stringify(item)}`).join(' ') 81 | } else if (type === 'aria2c') { 82 | return headerOption.map(item => ` header=${item}`).join('\n') 83 | } else if (type === 'idm') { 84 | return headerOption.map((item) => { 85 | const headers = item.split(': ') 86 | return `${headers[0]}: ${headers[1]}` 87 | }).join('\r\n') 88 | } 89 | } 90 | 91 | // 解析 RPC地址 返回验证数据 和地址 92 | parseURL (url) { 93 | const parseURL = new URL(url) 94 | let authStr = parseURL.username ? `${parseURL.username}:${decodeURI(parseURL.password)}` : null 95 | if (authStr) { 96 | if (!authStr.includes('token:')) { 97 | authStr = `Basic ${btoa(authStr)}` 98 | } 99 | } 100 | const paramsString = parseURL.hash.substr(1) 101 | const options = {} 102 | const searchParams = new URLSearchParams(paramsString) 103 | for (const searchParam of searchParams) { 104 | const [option, value] = searchParam 105 | options[option] = value.length ? value : 'enabled' 106 | } 107 | const path = parseURL.origin + parseURL.pathname 108 | return { authStr, path, options } 109 | } 110 | 111 | generateParameter (authStr, path, data) { 112 | if (authStr && authStr.startsWith('token')) { 113 | data.params.unshift(authStr) 114 | } 115 | const parameter = { 116 | url: path, 117 | options: { 118 | method: 'POST', 119 | headers: {}, 120 | body: JSON.stringify(data) 121 | } 122 | } 123 | if (authStr && authStr.startsWith('Basic')) { 124 | parameter.options.headers.Authorization = authStr 125 | } 126 | return parameter 127 | } 128 | 129 | // get aria2 version 130 | getVersion (rpcPath, element) { 131 | const data = { 132 | jsonrpc: '2.0', 133 | method: 'aria2.getVersion', 134 | id: 1, 135 | params: [] 136 | } 137 | const { authStr, path } = this.parseURL(rpcPath) 138 | this.sendToBackground('rpcVersion', this.generateParameter(authStr, path, data), (version) => { 139 | if (version) { 140 | element.innerText = `Aria2版本为: ${version}` 141 | } else { 142 | element.innerText = '错误,请查看是否开启Aria2' 143 | } 144 | }) 145 | } 146 | 147 | copyText (text) { 148 | if (navigator.clipboard) { 149 | navigator.clipboard.writeText(text).then(() => { 150 | this.showToast('拷贝成功~', 'inf') 151 | }).catch(() => { 152 | this.showToast('拷贝失败 QAQ', 'err') 153 | }) 154 | } else { 155 | this.showToast('拷贝失败 QAQ', 'err') 156 | } 157 | } 158 | 159 | // cookies format [{"url": "http://pan.baidu.com/", "name": "BDUSS"},{"url": "http://pcs.baidu.com/", "name": "pcsett"}] 160 | requestCookies (cookies) { 161 | return new Promise((resolve) => { 162 | this.sendToBackground('getCookies', cookies, (value) => { 163 | resolve(value) 164 | }) 165 | }) 166 | } 167 | 168 | aria2RPCMode (rpcPath, fileDownloadInfo) { 169 | const { authStr, path, options } = this.parseURL(rpcPath) 170 | const small = this.getConfigData('small') 171 | 172 | if (small) { 173 | fileDownloadInfo.sort((a, b) => a.size - b.size) 174 | } 175 | 176 | fileDownloadInfo.forEach((file) => { 177 | this.cookies = file.cookies 178 | const rpcData = { 179 | jsonrpc: '2.0', 180 | method: 'aria2.addUri', 181 | id: new Date().getTime(), 182 | params: [ 183 | [file.link], { 184 | out: file.name, 185 | header: this.getHeader() 186 | } 187 | ] 188 | } 189 | const sha1Check = this.getConfigData('sha1Check') 190 | const rpcOption = rpcData.params[1] 191 | const dir = this.getConfigData('downloadPath') 192 | if (dir) { 193 | rpcOption.dir = dir 194 | } 195 | if (sha1Check) { 196 | rpcOption.checksum = `sha-1=${file.sha1}` 197 | } 198 | if (options) { 199 | for (const key in options) { 200 | rpcOption[key] = options[key] 201 | } 202 | } 203 | this.sendToBackground('rpcData', this.generateParameter(authStr, path, rpcData), (success) => { 204 | if (success) { 205 | this.showToast('下载成功!赶紧去看看吧~', 'inf') 206 | } else { 207 | this.showToast('下载失败!是不是没有开启Aria2?', 'err') 208 | } 209 | }) 210 | }) 211 | } 212 | 213 | aria2TXTMode (fileDownloadInfo) { 214 | const aria2CmdTxt = [] 215 | const aria2Txt = [] 216 | const idmTxt = [] 217 | const downloadLinkTxt = [] 218 | const prefixTxt = 'data:text/plain;charset=utf-8,' 219 | fileDownloadInfo.forEach((file) => { 220 | this.cookies = file.cookies 221 | let aria2CmdLine = `aria2c -c -s10 -k1M -x16 --enable-rpc=false -o ${JSON.stringify(file.name)} ${this.getHeader('aria2Cmd')} ${JSON.stringify(file.link)}` 222 | let aria2Line = [file.link, this.getHeader('aria2c'), ` out=${file.name}`].join('\n') 223 | const sha1Check = this.getConfigData('sha1Check') 224 | if (sha1Check) { 225 | aria2CmdLine += ` --checksum=sha-1=${file.sha1}` 226 | aria2Line += `\n checksum=sha-1=${file.sha1}` 227 | } 228 | aria2CmdTxt.push(aria2CmdLine) 229 | aria2Txt.push(aria2Line) 230 | const idmLine = ['<', file.link, this.getHeader('idm'), '>'].join('\r\n') 231 | idmTxt.push(idmLine) 232 | downloadLinkTxt.push(file.link) 233 | }) 234 | document.querySelector('#aria2CmdTxt').value = `${aria2CmdTxt.join('\n')}` 235 | document.querySelector('#aria2Txt').href = `${prefixTxt}${encodeURIComponent(aria2Txt.join('\n'))}` 236 | document.querySelector('#idmTxt').href = `${prefixTxt}${encodeURIComponent(idmTxt.join('\r\n') + '\r\n')}` 237 | document.querySelector('#downloadLinkTxt').href = `${prefixTxt}${encodeURIComponent(downloadLinkTxt.join('\n'))}` 238 | document.querySelector('#copyDownloadLinkTxt').dataset.link = downloadLinkTxt.join('\n') 239 | } 240 | } 241 | 242 | export default new Core() 243 | -------------------------------------------------------------------------------- /src/js/lib/ui.js: -------------------------------------------------------------------------------- 1 | import Core from './core' 2 | import Store from './store' 3 | 4 | class UI { 5 | constructor () { 6 | this.version = '0.5.1' 7 | this.updateDate = '2022/10/02' 8 | Store.on('updateView', (configData) => { 9 | this.updateSetting(configData) 10 | this.updateMenu(configData) 11 | }) 12 | } 13 | 14 | init () { 15 | this.context = document.querySelector('iframe[rel="wangpan"]').contentDocument 16 | this.addSettingUI() 17 | this.addTextExport() 18 | Store.trigger('initConfigData') 19 | } 20 | 21 | addMenu (element, position) { 22 | const menu = ` 23 |
24 | 导出下载 25 |
26 | 批量打开 27 | 文本导出 28 | 设置 29 |
30 |
` 31 | if (element) { 32 | element.insertAdjacentHTML(position, menu) 33 | } else { 34 | return 35 | } 36 | const exportMenu = this.context.querySelector('#exportMenu') 37 | exportMenu.addEventListener('mouseenter', () => { 38 | exportMenu.classList.add('open-o') 39 | }) 40 | exportMenu.addEventListener('mouseleave', () => { 41 | exportMenu.classList.remove('open-o') 42 | }) 43 | const settingButton = this.context.querySelector('#settingButton') 44 | const settingMenu = document.querySelector('#settingMenu') 45 | settingButton.addEventListener('click', (event) => { 46 | settingMenu.classList.add('open-o') 47 | }) 48 | // fix click select file 49 | const aria2List = this.context.querySelector('#aria2List') 50 | aria2List.addEventListener('mousedown', (event) => { 51 | event.stopPropagation() 52 | }) 53 | } 54 | 55 | addContextMenuRPCSectionWithCallback (callback) { 56 | const addContextMenuRPCSection = (node) => { 57 | const dom = '
    ' 58 | node.insertAdjacentHTML('beforebegin', dom) 59 | if (this.mostRecentConfigData) { 60 | this.updateMenu(this.mostRecentConfigData) 61 | } 62 | if (callback) { 63 | callback() 64 | } 65 | } 66 | 67 | const contextMenuNode = this.context.querySelector('body > .context-menu .cell') 68 | if (contextMenuNode) { 69 | addContextMenuRPCSection(contextMenuNode) 70 | } else if ('MutationObserver' in window) { 71 | const body = this.context.querySelector('body') 72 | const observer = new MutationObserver((mutationsList) => { 73 | const contextMenuNode = this.context.querySelector('body > .context-menu .cell') 74 | if (contextMenuNode) { 75 | observer.disconnect() 76 | addContextMenuRPCSection(contextMenuNode) 77 | } 78 | }) 79 | observer.observe(body, { 80 | childList: true 81 | }) 82 | } 83 | } 84 | 85 | resetMenu () { 86 | this.context.querySelectorAll('#more-menu-rpc-section li').forEach((item) => { 87 | item.remove() 88 | }) 89 | this.context.querySelectorAll('.rpc-button').forEach((rpc) => { 90 | rpc.remove() 91 | }) 92 | } 93 | 94 | updateMenu (configData) { 95 | this.resetMenu() 96 | const { rpcList } = configData 97 | let rpcDOMList = '' 98 | let contextMenuDOMList = '' 99 | rpcList.forEach((rpc) => { 100 | const rpcDOM = `${rpc.name}` 101 | rpcDOMList += rpcDOM 102 | contextMenuDOMList += `
  • ${rpc.name}
  • ` 103 | }) 104 | this.context.querySelector('#aria2List').insertAdjacentHTML('afterbegin', rpcDOMList) 105 | 106 | const contextMenuSection = this.context.querySelector('#more-menu-rpc-section ul') 107 | if (contextMenuSection) { 108 | contextMenuSection.insertAdjacentHTML('afterbegin', contextMenuDOMList) 109 | } 110 | } 111 | 112 | addTextExport () { 113 | const text = ` 114 | ` 133 | document.body.insertAdjacentHTML('beforeend', text) 134 | const textMenu = document.querySelector('#textMenu') 135 | const close = textMenu.querySelector('.modal-close') 136 | const copyDownloadLinkTxt = textMenu.querySelector('#copyDownloadLinkTxt') 137 | copyDownloadLinkTxt.addEventListener('click', () => { 138 | Core.copyText(copyDownloadLinkTxt.dataset.link) 139 | }) 140 | close.addEventListener('click', () => { 141 | textMenu.classList.remove('open-o') 142 | this.resetTextExport() 143 | }) 144 | } 145 | 146 | resetTextExport () { 147 | const textMenu = document.querySelector('#textMenu') 148 | textMenu.querySelector('#aria2Txt').href = '' 149 | textMenu.querySelector('#idmTxt').href = '' 150 | textMenu.querySelector('#downloadLinkTxt').href = '' 151 | textMenu.querySelector('#aria2CmdTxt').value = '' 152 | textMenu.querySelector('#copyDownloadLinkTxt').dataset.link = '' 153 | } 154 | 155 | addSettingUI () { 156 | const setting = ` 157 | ` 272 | document.body.insertAdjacentHTML('beforeend', setting) 273 | const settingMenu = document.querySelector('#settingMenu') 274 | const close = settingMenu.querySelector('.modal-close') 275 | close.addEventListener('click', () => { 276 | settingMenu.classList.remove('open-o') 277 | this.resetSetting() 278 | }) 279 | const addRPC = document.querySelector('#addRPC') 280 | addRPC.addEventListener('click', () => { 281 | const rpcDOMList = document.querySelectorAll('.rpc-s') 282 | const RPC = ` 283 |
    284 |
    285 | 286 |
    287 |
    288 | 289 |
    290 |
    ` 291 | Array.from(rpcDOMList).pop().insertAdjacentHTML('afterend', RPC) 292 | }) 293 | const apply = document.querySelector('#apply') 294 | const message = document.querySelector('#message') 295 | apply.addEventListener('click', () => { 296 | this.saveSetting() 297 | message.innerText = '设置已保存' 298 | }) 299 | 300 | const reset = document.querySelector('#reset') 301 | reset.addEventListener('click', () => { 302 | Store.trigger('clearConfigData') 303 | message.innerText = '设置已重置' 304 | }) 305 | 306 | const testAria2 = document.querySelector('#testAria2') 307 | testAria2.addEventListener('click', () => { 308 | Core.getVersion(Store.getConfigData('rpcList')[0].url, testAria2) 309 | }) 310 | 311 | const userAgentField = document.querySelector('.userAgent-s') 312 | const browserUACheckbox = document.querySelector('.browser-userAgent-s') 313 | browserUACheckbox.addEventListener('change', () => { 314 | userAgentField.disabled = browserUACheckbox.checked 315 | }) 316 | } 317 | 318 | resetSetting () { 319 | const message = document.querySelector('#message') 320 | message.innerText = '' 321 | const testAria2 = document.querySelector('#testAria2') 322 | testAria2.innerText = '测试连接,成功显示版本号' 323 | } 324 | 325 | updateSetting (configData) { 326 | const { rpcList, configSync, sha1Check, vip, small, interval, downloadPath, userAgent, browserUserAgent, referer, headers } = configData 327 | // reset dom 328 | document.querySelectorAll('.rpc-s').forEach((rpc, index) => { 329 | if (index !== 0) { 330 | rpc.remove() 331 | } 332 | }) 333 | rpcList.forEach((rpc, index) => { 334 | const rpcDOMList = document.querySelectorAll('.rpc-s') 335 | if (index === 0) { 336 | rpcDOMList[index].querySelector('.name-s').value = rpc.name 337 | rpcDOMList[index].querySelector('.url-s').value = rpc.url 338 | } else { 339 | const RPC = ` 340 |
    341 |
    342 | 343 |
    344 |
    345 | 346 |
    347 |
    ` 348 | Array.from(rpcDOMList).pop().insertAdjacentHTML('afterend', RPC) 349 | } 350 | }) 351 | document.querySelector('.configSync-s').checked = configSync 352 | document.querySelector('.sha1Check-s').checked = sha1Check 353 | document.querySelector('.vip-s').checked = vip 354 | document.querySelector('.small-s').checked = small 355 | document.querySelector('.interval-s').value = interval 356 | document.querySelector('.downloadPath-s').value = downloadPath 357 | document.querySelector('.userAgent-s').value = userAgent 358 | document.querySelector('.userAgent-s').disabled = browserUserAgent 359 | document.querySelector('.browser-userAgent-s').checked = browserUserAgent 360 | document.querySelector('.referer-s').value = referer 361 | document.querySelector('.headers-s').value = headers 362 | 363 | this.mostRecentConfigData = configData 364 | } 365 | 366 | saveSetting () { 367 | const rpcDOMList = document.querySelectorAll('.rpc-s') 368 | const rpcList = Array.from(rpcDOMList).map((rpc) => { 369 | const name = rpc.querySelector('.name-s').value 370 | const url = rpc.querySelector('.url-s').value 371 | if (name && url) { 372 | return { name, url } 373 | } else { 374 | return null 375 | } 376 | }).filter(el => el) 377 | const configSync = document.querySelector('.configSync-s').checked 378 | const sha1Check = document.querySelector('.sha1Check-s').checked 379 | const vip = document.querySelector('.vip-s').checked 380 | const small = document.querySelector('.small-s').checked 381 | const interval = document.querySelector('.interval-s').value 382 | const downloadPath = document.querySelector('.downloadPath-s').value 383 | const userAgent = document.querySelector('.userAgent-s').value 384 | const browserUserAgent = document.querySelector('.browser-userAgent-s').checked 385 | const referer = document.querySelector('.referer-s').value 386 | const headers = document.querySelector('.headers-s').value 387 | 388 | const configData = { 389 | rpcList, 390 | configSync, 391 | sha1Check, 392 | vip, 393 | small, 394 | interval, 395 | downloadPath, 396 | userAgent, 397 | browserUserAgent, 398 | referer, 399 | headers 400 | } 401 | Store.trigger('setConfigData', configData) 402 | } 403 | } 404 | 405 | export default new UI() 406 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /release/js/home.js: -------------------------------------------------------------------------------- 1 | !function(){"use strict";var e=new class extends class{constructor(){this._listeners={}}on(e,t){(this._listeners[e]=this._listeners[e]||[]).push(t)}trigger(e,t){(this._listeners[e]||[]).forEach((e=>e(t)))}off(e){delete this._listeners[e]}}{constructor(){super(),this.defaultRPC=[{name:"ARIA2 RPC",url:"http://localhost:6800/jsonrpc"}],this.defaultUserAgent="Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 115Browser/5.1.3",this.defaultReferer="https://115.com/",this.defaultConfigData={rpcList:this.defaultRPC,configSync:!1,sha1Check:!1,vip:!0,small:!1,interval:300,downloadPath:"",userAgent:this.defaultUserAgent,browserUserAgent:!0,referer:this.defaultReferer,headers:""},this.configData={},this.on("initConfigData",this.init.bind(this)),this.on("setConfigData",this.set.bind(this)),this.on("clearConfigData",this.clear.bind(this))}init(){chrome.storage.sync.get(null,(e=>{for(const t in e)chrome.storage.local.set({key:e[t]},(()=>{console.log("chrome first local set: %s, %s",t,e[t])}))})),chrome.storage.local.get(null,(e=>{this.configData=Object.assign({},this.defaultConfigData,e),this.trigger("updateView",this.configData)}))}getConfigData(e=null){return e?this.configData[e]:this.configData}set(e){this.configData=e,this.save(e),this.trigger("updateView",e)}save(e){for(const t in e)chrome.storage.local.set({[t]:e[t]},(()=>{console.log("chrome local set: %s, %s",t,e[t])})),!0===e.configSync&&chrome.storage.sync.set({[t]:e[t]},(()=>{console.log("chrome sync set: %s, %s",t,e[t])}))}clear(){chrome.storage.sync.clear(),chrome.storage.local.clear(),this.configData=this.defaultConfigData,this.trigger("updateView",this.configData)}};var t=new class{constructor(){this.cookies={}}httpSend({url:e,options:t},n,r){fetch(e,t).then((e=>{e.ok?e.json().then((e=>{n(e)})):r(e)})).catch((e=>{r(e)}))}getConfigData(t=null){return e.getConfigData(t)}objectToQueryString(e){return Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}sendToBackground(e,t,n){chrome.runtime.sendMessage({method:e,data:t},n)}showToast(e,t){window.postMessage({type:"showToast",data:{message:e,type:t}},location.origin)}getHashParameter(e){const t=window.location.hash.substr(1);return new URLSearchParams(t).get(e)}formatCookies(){const e=[];for(const t in this.cookies)e.push(`${t}=${this.cookies[t]}`);return e.join("; ")}getHeader(e="RPC"){const t=[],n=this.getConfigData("browserUserAgent");let r=this.getConfigData("userAgent");if(n){const e=navigator.userAgent;e&&e.length&&(r=e)}t.push(`User-Agent: ${r}`),t.push(`Referer: ${this.getConfigData("referer")}`),t.push(`Cookie: ${this.formatCookies()}`);const o=this.getConfigData("headers");return o&&o.split("\n").forEach((e=>{t.push(e)})),"RPC"===e?t:"aria2Cmd"===e?t.map((e=>`--header ${JSON.stringify(e)}`)).join(" "):"aria2c"===e?t.map((e=>` header=${e}`)).join("\n"):"idm"===e?t.map((e=>{const t=e.split(": ");return`${t[0].toLowerCase()}: ${t[1]}`})).join("\r\n"):void 0}parseURL(e){const t=new URL(e);let n=t.username?`${t.username}:${decodeURI(t.password)}`:null;n&&(n.includes("token:")||(n=`Basic ${btoa(n)}`));const r=t.hash.substr(1),o={},i=new URLSearchParams(r);for(const e of i){const[t,n]=e;o[t]=n.length?n:"enabled"}return{authStr:n,path:t.origin+t.pathname,options:o}}generateParameter(e,t,n){e&&e.startsWith("token")&&n.params.unshift(e);const r={url:t,options:{method:"POST",headers:{},body:JSON.stringify(n)}};return e&&e.startsWith("Basic")&&(r.options.headers.Authorization=e),r}getVersion(e,t){const{authStr:n,path:r}=this.parseURL(e);this.sendToBackground("rpcVersion",this.generateParameter(n,r,{jsonrpc:"2.0",method:"aria2.getVersion",id:1,params:[]}),(e=>{t.innerText=e?`Aria2版本为: ${e}`:"错误,请查看是否开启Aria2"}))}copyText(e){navigator.clipboard?navigator.clipboard.writeText(e).then((()=>{this.showToast("拷贝成功~","inf")})).catch((()=>{this.showToast("拷贝失败 QAQ","err")})):this.showToast("拷贝失败 QAQ","err")}requestCookies(e){return new Promise((t=>{this.sendToBackground("getCookies",e,(e=>{t(e)}))}))}aria2RPCMode(e,t){const{authStr:n,path:r,options:o}=this.parseURL(e);this.getConfigData("small")&&t.sort(((e,t)=>e.size-t.size)),t.forEach((e=>{this.cookies=e.cookies;const t={jsonrpc:"2.0",method:"aria2.addUri",id:(new Date).getTime(),params:[[e.link],{out:e.name,header:this.getHeader()}]},i=this.getConfigData("sha1Check"),s=t.params[1],a=this.getConfigData("downloadPath");if(a&&(s.dir=a),i&&(s.checksum=`sha-1=${e.sha1}`),o)for(const e in o)s[e]=o[e];this.sendToBackground("rpcData",this.generateParameter(n,r,t),(e=>{e?this.showToast("下载成功!赶紧去看看吧~","inf"):this.showToast("下载失败!是不是没有开启Aria2?","err")}))}))}aria2TXTMode(e){const t=[],n=[],r=[],o=[],i="data:text/plain;charset=utf-8,";e.forEach((e=>{this.cookies=e.cookies;let i=`aria2c -c -s10 -k1M -x16 --enable-rpc=false -o ${JSON.stringify(e.name)} ${this.getHeader("aria2Cmd")} ${JSON.stringify(e.link)}`,s=[e.link,this.getHeader("aria2c"),` out=${e.name}`].join("\n");this.getConfigData("sha1Check")&&(i+=` --checksum=sha-1=${e.sha1}`,s+=`\n checksum=sha-1=${e.sha1}`),t.push(i),n.push(s);const a=["<",e.link,this.getHeader("idm"),">"].join("\r\n");r.push(a),o.push(e.link)})),document.querySelector("#aria2CmdTxt").value=`${t.join("\n")}`,document.querySelector("#aria2Txt").href=`${i}${encodeURIComponent(n.join("\n"))}`,document.querySelector("#idmTxt").href=`${i}${encodeURIComponent(r.join("\r\n")+"\r\n")}`,document.querySelector("#downloadLinkTxt").href=`${i}${encodeURIComponent(o.join("\n"))}`,document.querySelector("#copyDownloadLinkTxt").dataset.link=o.join("\n")}};var n=new class{constructor(){this.version="0.5.1",this.updateDate="2022/10/02",e.on("updateView",(e=>{this.updateSetting(e),this.updateMenu(e)}))}init(){this.context=document.querySelector('iframe[rel="wangpan"]').contentDocument,this.addSettingUI(),this.addTextExport(),e.trigger("initConfigData")}addMenu(e,t){if(!e)return;e.insertAdjacentHTML(t,'\n ');const n=this.context.querySelector("#exportMenu");n.addEventListener("mouseenter",(()=>{n.classList.add("open-o")})),n.addEventListener("mouseleave",(()=>{n.classList.remove("open-o")}));const r=this.context.querySelector("#settingButton"),o=document.querySelector("#settingMenu");r.addEventListener("click",(e=>{o.classList.add("open-o")}));this.context.querySelector("#aria2List").addEventListener("mousedown",(e=>{e.stopPropagation()}))}addContextMenuRPCSectionWithCallback(e){const t=t=>{t.insertAdjacentHTML("beforebegin",'
      '),this.mostRecentConfigData&&this.updateMenu(this.mostRecentConfigData),e&&e()},n=this.context.querySelector("body > .context-menu .cell");if(n)t(n);else if("MutationObserver"in window){const e=this.context.querySelector("body"),n=new MutationObserver((e=>{const r=this.context.querySelector("body > .context-menu .cell");r&&(n.disconnect(),t(r))}));n.observe(e,{childList:!0})}}resetMenu(){this.context.querySelectorAll("#more-menu-rpc-section li").forEach((e=>{e.remove()})),this.context.querySelectorAll(".rpc-button").forEach((e=>{e.remove()}))}updateMenu(e){this.resetMenu();const{rpcList:t}=e;let n="",r="";t.forEach((e=>{const t=`${e.name}`;n+=t,r+=`
    • ${e.name}
    • `})),this.context.querySelector("#aria2List").insertAdjacentHTML("afterbegin",n);const o=this.context.querySelector("#more-menu-rpc-section ul");o&&o.insertAdjacentHTML("afterbegin",r)}addTextExport(){document.body.insertAdjacentHTML("beforeend",'\n ');const e=document.querySelector("#textMenu"),n=e.querySelector(".modal-close"),r=e.querySelector("#copyDownloadLinkTxt");r.addEventListener("click",(()=>{t.copyText(r.dataset.link)})),n.addEventListener("click",(()=>{e.classList.remove("open-o"),this.resetTextExport()}))}resetTextExport(){const e=document.querySelector("#textMenu");e.querySelector("#aria2Txt").href="",e.querySelector("#idmTxt").href="",e.querySelector("#downloadLinkTxt").href="",e.querySelector("#aria2CmdTxt").value="",e.querySelector("#copyDownloadLinkTxt").dataset.link=""}addSettingUI(){const n=`\n `;document.body.insertAdjacentHTML("beforeend",n);const r=document.querySelector("#settingMenu");r.querySelector(".modal-close").addEventListener("click",(()=>{r.classList.remove("open-o"),this.resetSetting()}));document.querySelector("#addRPC").addEventListener("click",(()=>{const e=document.querySelectorAll(".rpc-s");Array.from(e).pop().insertAdjacentHTML("afterend",'\n
      \n
      \n \n
      \n
      \n \n
      \n
      \x3c!-- /.setting-menu-row --\x3e')}));const o=document.querySelector("#apply"),i=document.querySelector("#message");o.addEventListener("click",(()=>{this.saveSetting(),i.innerText="设置已保存"}));document.querySelector("#reset").addEventListener("click",(()=>{e.trigger("clearConfigData"),i.innerText="设置已重置"}));const s=document.querySelector("#testAria2");s.addEventListener("click",(()=>{t.getVersion(e.getConfigData("rpcList")[0].url,s)}));const a=document.querySelector(".userAgent-s"),u=document.querySelector(".browser-userAgent-s");u.addEventListener("change",(()=>{a.disabled=u.checked}))}resetSetting(){document.querySelector("#message").innerText="";document.querySelector("#testAria2").innerText="测试连接,成功显示版本号"}updateSetting(e){const{rpcList:t,configSync:n,sha1Check:r,vip:o,small:i,interval:s,downloadPath:a,userAgent:u,browserUserAgent:l,referer:c,headers:p}=e;document.querySelectorAll(".rpc-s").forEach(((e,t)=>{0!==t&&e.remove()})),t.forEach(((e,t)=>{const n=document.querySelectorAll(".rpc-s");if(0===t)n[t].querySelector(".name-s").value=e.name,n[t].querySelector(".url-s").value=e.url;else{const t=`\n
      \n
      \n \n
      \n
      \n \n
      \n
      \x3c!-- /.setting-menu-row --\x3e`;Array.from(n).pop().insertAdjacentHTML("afterend",t)}})),document.querySelector(".configSync-s").checked=n,document.querySelector(".sha1Check-s").checked=r,document.querySelector(".vip-s").checked=o,document.querySelector(".small-s").checked=i,document.querySelector(".interval-s").value=s,document.querySelector(".downloadPath-s").value=a,document.querySelector(".userAgent-s").value=u,document.querySelector(".userAgent-s").disabled=l,document.querySelector(".browser-userAgent-s").checked=l,document.querySelector(".referer-s").value=c,document.querySelector(".headers-s").value=p,this.mostRecentConfigData=e}saveSetting(){const t=document.querySelectorAll(".rpc-s"),n={rpcList:Array.from(t).map((e=>{const t=e.querySelector(".name-s").value,n=e.querySelector(".url-s").value;return t&&n?{name:t,url:n}:null})).filter((e=>e)),configSync:document.querySelector(".configSync-s").checked,sha1Check:document.querySelector(".sha1Check-s").checked,vip:document.querySelector(".vip-s").checked,small:document.querySelector(".small-s").checked,interval:document.querySelector(".interval-s").value,downloadPath:document.querySelector(".downloadPath-s").value,userAgent:document.querySelector(".userAgent-s").value,browserUserAgent:document.querySelector(".browser-userAgent-s").checked,referer:document.querySelector(".referer-s").value,headers:document.querySelector(".headers-s").value};e.trigger("setConfigData",n)}};var r,o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={exports:{}};r=i,function(e){function t(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function n(e,n,r,o,i,s){return t((a=t(t(n,e),t(o,s)))<<(u=i)|a>>>32-u,r);var a,u}function o(e,t,r,o,i,s,a){return n(t&r|~t&o,e,t,i,s,a)}function i(e,t,r,o,i,s,a){return n(t&o|r&~o,e,t,i,s,a)}function s(e,t,r,o,i,s,a){return n(t^r^o,e,t,i,s,a)}function a(e,t,r,o,i,s,a){return n(r^(t|~o),e,t,i,s,a)}function u(e,n){var r,u,l,c,p;e[n>>5]|=128<>>9<<4)]=n;var h=1732584193,d=-271733879,f=-1732584194,g=271733878;for(r=0;r>5]>>>t%32&255);return n}function c(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function h(e){return unescape(encodeURIComponent(e))}function d(e){return function(e){return l(u(c(e),8*e.length))}(h(e))}function f(e,t){return function(e,t){var n,r,o=c(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=u(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=u(i.concat(c(t)),512+8*t.length),l(u(s.concat(r),640))}(h(e),h(t))}function g(e,t,n){return t?n?f(t,e):p(f(t,e)):n?d(e):p(d(e))}r.exports?r.exports=g:e.md5=g}(o);var s=i.exports,a={exports:{}};!function(e){var t=function(e){var n=1e7,r=9007199254740992,o=h(r),i="0123456789abcdefghijklmnopqrstuvwxyz",s="function"==typeof BigInt;function a(e,t,n,r){return void 0===e?a[0]:void 0!==t&&(10!=+t||n)?H(e,t,n,r):Q(e)}function u(e,t){this.value=e,this.sign=t,this.isSmall=!1}function l(e){this.value=e,this.sign=e<0,this.isSmall=!0}function c(e){this.value=e}function p(e){return-r0?Math.floor(e):Math.ceil(e)}function m(e,t){var r,o,i=e.length,s=t.length,a=new Array(i),u=0,l=n;for(o=0;o=l?1:0,a[o]=r-u*l;for(;o0&&a.push(u),a}function y(e,t){return e.length>=t.length?m(e,t):m(t,e)}function b(e,t){var r,o,i=e.length,s=new Array(i),a=n;for(o=0;o0;)s[o++]=t%a,t=Math.floor(t/a);return s}function w(e,t){var r,o,i=e.length,s=t.length,a=new Array(i),u=0,l=n;for(r=0;r0;)s[o++]=u%a,u=Math.floor(u/a);return s}function q(e,t){for(var n=[];t-- >0;)n.push(0);return n.concat(e)}function T(e,t){var n=Math.max(e.length,t.length);if(n<=30)return x(e,t);n=Math.ceil(n/2);var r=e.slice(n),o=e.slice(0,n),i=t.slice(n),s=t.slice(0,n),a=T(o,s),u=T(r,i),l=T(y(o,r),y(s,i)),c=y(y(a,q(w(w(l,a),u),n)),q(u,2*n));return f(c),c}function C(e,t,r){return new u(e=0;--n)o=(i=1e7*o+e[n])-(r=v(i/t))*t,a[n]=0|r;return[a,0|o]}function E(e,t){var r,o=Q(t);if(s)return[new c(e.value/o.value),new c(e.value%o.value)];var i,p=e.value,m=o.value;if(0===m)throw new Error("Cannot divide by zero");if(e.isSmall)return o.isSmall?[new l(v(p/m)),new l(p%m)]:[a[0],e];if(o.isSmall){if(1===m)return[e,a[0]];if(-1==m)return[e.negate(),a[0]];var y=Math.abs(m);if(y=0;o--){for(r=h-1,y[o+p]!==v&&(r=Math.floor((y[o+p]*h+y[o+p-1])/v)),i=0,s=0,u=b.length,a=0;al&&(i=(i+1)*h),r=Math.ceil(i/s);do{if(L(a=k(t,r),p)<=0)break;r--}while(r);c.push(r),p=w(p,a)}return c.reverse(),[d(c),d(p)]}(p,m),i=r[0];var x=e.sign!==o.sign,q=r[1],T=e.sign;return"number"==typeof i?(x&&(i=-i),i=new l(i)):i=new u(i,x),"number"==typeof q?(T&&(q=-q),q=new l(q)):q=new u(q,T),[i,q]}function L(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function P(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function D(e,n){for(var r,o,i,s=e.prev(),a=s,u=0;a.isEven();)a=a.divide(2),u++;e:for(o=0;o=0?r=w(e,t):(r=w(t,e),n=!n),"number"==typeof(r=d(r))?(n&&(r=-r),new l(r)):new u(r,n)}(n,r,this.sign)},u.prototype.minus=u.prototype.subtract,l.prototype.subtract=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var r=t.value;return t.isSmall?new l(n-r):S(r,Math.abs(n),n>=0)},l.prototype.minus=l.prototype.subtract,c.prototype.subtract=function(e){return new c(this.value-Q(e).value)},c.prototype.minus=c.prototype.subtract,u.prototype.negate=function(){return new u(this.value,!this.sign)},l.prototype.negate=function(){var e=this.sign,t=new l(-this.value);return t.sign=!e,t},c.prototype.negate=function(){return new c(-this.value)},u.prototype.abs=function(){return new u(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},c.prototype.abs=function(){return new c(this.value>=0?this.value:-this.value)},u.prototype.multiply=function(e){var t,r,o,i=Q(e),s=this.value,l=i.value,c=this.sign!==i.sign;if(i.isSmall){if(0===l)return a[0];if(1===l)return this;if(-1===l)return this.negate();if((t=Math.abs(l))0?T(s,l):x(s,l),c)},u.prototype.times=u.prototype.multiply,l.prototype._multiplyBySmall=function(e){return p(e.value*this.value)?new l(e.value*this.value):C(Math.abs(e.value),h(Math.abs(this.value)),this.sign!==e.sign)},u.prototype._multiplyBySmall=function(e){return 0===e.value?a[0]:1===e.value?this:-1===e.value?this.negate():C(Math.abs(e.value),this.value,this.sign!==e.sign)},l.prototype.multiply=function(e){return Q(e)._multiplyBySmall(this)},l.prototype.times=l.prototype.multiply,c.prototype.multiply=function(e){return new c(this.value*Q(e).value)},c.prototype.times=c.prototype.multiply,u.prototype.square=function(){return new u(A(this.value),!1)},l.prototype.square=function(){var e=this.value*this.value;return p(e)?new l(e):new u(A(h(Math.abs(this.value))),!1)},c.prototype.square=function(e){return new c(this.value*this.value)},u.prototype.divmod=function(e){var t=E(this,e);return{quotient:t[0],remainder:t[1]}},c.prototype.divmod=l.prototype.divmod=u.prototype.divmod,u.prototype.divide=function(e){return E(this,e)[0]},c.prototype.over=c.prototype.divide=function(e){return new c(this.value/Q(e).value)},l.prototype.over=l.prototype.divide=u.prototype.over=u.prototype.divide,u.prototype.mod=function(e){return E(this,e)[1]},c.prototype.mod=c.prototype.remainder=function(e){return new c(this.value%Q(e).value)},l.prototype.remainder=l.prototype.mod=u.prototype.remainder=u.prototype.mod,u.prototype.pow=function(e){var t,n,r,o=Q(e),i=this.value,s=o.value;if(0===s)return a[1];if(0===i)return a[0];if(1===i)return a[1];if(-1===i)return o.isEven()?a[1]:a[-1];if(o.sign)return a[0];if(!o.isSmall)throw new Error("The exponent "+o.toString()+" is too large.");if(this.isSmall&&p(t=Math.pow(i,s)))return new l(v(t));for(n=this,r=a[1];!0&s&&(r=r.times(n),--s),0!==s;)s/=2,n=n.square();return r},l.prototype.pow=u.prototype.pow,c.prototype.pow=function(e){var t=Q(e),n=this.value,r=t.value,o=BigInt(0),i=BigInt(1),s=BigInt(2);if(r===o)return a[1];if(n===o)return a[0];if(n===i)return a[1];if(n===BigInt(-1))return t.isEven()?a[1]:a[-1];if(t.isNegative())return new c(o);for(var u=this,l=a[1];(r&i)===i&&(l=l.times(u),--r),r!==o;)r/=s,u=u.square();return l},u.prototype.modPow=function(e,t){if(e=Q(e),(t=Q(t)).isZero())throw new Error("Cannot take modPow with modulus 0");var n=a[1],r=this.mod(t);for(e.isNegative()&&(e=e.multiply(a[-1]),r=r.modInv(t));e.isPositive();){if(r.isZero())return a[0];e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t)}return n},c.prototype.modPow=l.prototype.modPow=u.prototype.modPow,u.prototype.compareAbs=function(e){var t=Q(e),n=this.value,r=t.value;return t.isSmall?1:L(n,r)},l.prototype.compareAbs=function(e){var t=Q(e),n=Math.abs(this.value),r=t.value;return t.isSmall?n===(r=Math.abs(r))?0:n>r?1:-1:-1},c.prototype.compareAbs=function(e){var t=this.value,n=Q(e).value;return(t=t>=0?t:-t)===(n=n>=0?n:-n)?0:t>n?1:-1},u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=Q(e),n=this.value,r=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:L(n,r)*(this.sign?-1:1)},u.prototype.compareTo=u.prototype.compare,l.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=Q(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0!==t.sign?n<0?-1:1:n<0?1:-1},l.prototype.compareTo=l.prototype.compare,c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,n=Q(e).value;return t===n?0:t>n?1:-1},c.prototype.compareTo=c.prototype.compare,u.prototype.equals=function(e){return 0===this.compare(e)},c.prototype.eq=c.prototype.equals=l.prototype.eq=l.prototype.equals=u.prototype.eq=u.prototype.equals,u.prototype.notEquals=function(e){return 0!==this.compare(e)},c.prototype.neq=c.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=u.prototype.neq=u.prototype.notEquals,u.prototype.greater=function(e){return this.compare(e)>0},c.prototype.gt=c.prototype.greater=l.prototype.gt=l.prototype.greater=u.prototype.gt=u.prototype.greater,u.prototype.lesser=function(e){return this.compare(e)<0},c.prototype.lt=c.prototype.lesser=l.prototype.lt=l.prototype.lesser=u.prototype.lt=u.prototype.lesser,u.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},c.prototype.geq=c.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals,u.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},c.prototype.leq=c.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals,u.prototype.isEven=function(){return 0==(1&this.value[0])},l.prototype.isEven=function(){return 0==(1&this.value)},c.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},u.prototype.isOdd=function(){return 1==(1&this.value[0])},l.prototype.isOdd=function(){return 1==(1&this.value)},c.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},u.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},c.prototype.isPositive=l.prototype.isPositive,u.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},c.prototype.isNegative=l.prototype.isNegative,u.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return 1===Math.abs(this.value)},c.prototype.isUnit=function(){return this.abs().value===BigInt(1)},u.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return 0===this.value},c.prototype.isZero=function(){return this.value===BigInt(0)},u.prototype.isDivisibleBy=function(e){var t=Q(e);return!t.isZero()&&(!!t.isUnit()||(0===t.compareAbs(2)?this.isEven():this.mod(t).isZero()))},c.prototype.isDivisibleBy=l.prototype.isDivisibleBy=u.prototype.isDivisibleBy,u.prototype.isPrime=function(n){var r=P(this);if(r!==e)return r;var o=this.abs(),i=o.bitLength();if(i<=64)return D(o,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var s=Math.log(2)*i.toJSNumber(),a=Math.ceil(!0===n?2*Math.pow(s,2):s),u=[],l=0;l-r?new l(e-1):new u(o,!0)},c.prototype.prev=function(){return new c(this.value-BigInt(1))};for(var j=[1];2*j[j.length-1]<=n;)j.push(2*j[j.length-1]);var I=j.length,N=j[I-1];function O(e){return Math.abs(e)<=n}function R(e,n,r){n=Q(n);for(var o=e.isNegative(),i=n.isNegative(),s=o?e.not():e,a=i?n.not():n,u=0,l=0,c=null,p=null,h=[];!s.isZero()||!a.isZero();)u=(c=E(s,N))[1].toJSNumber(),o&&(u=N-1-u),l=(p=E(a,N))[1].toJSNumber(),i&&(l=N-1-l),s=c[0],a=p[0],h.push(r(u,l));for(var d=0!==r(o?1:0,i?1:0)?t(-1):t(0),f=h.length-1;f>=0;f-=1)d=d.multiply(N).add(t(h[f]));return d}u.prototype.shiftLeft=function(e){var t=Q(e).toJSNumber();if(!O(t))throw new Error(String(t)+" is too large for shifting.");if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=I;)n=n.multiply(N),t-=I-1;return n.multiply(j[t])},c.prototype.shiftLeft=l.prototype.shiftLeft=u.prototype.shiftLeft,u.prototype.shiftRight=function(e){var t,n=Q(e).toJSNumber();if(!O(n))throw new Error(String(n)+" is too large for shifting.");if(n<0)return this.shiftLeft(-n);for(var r=this;n>=I;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;r=(t=E(r,N))[1].isNegative()?t[0].prev():t[0],n-=I-1}return(t=E(r,j[n]))[1].isNegative()?t[0].prev():t[0]},c.prototype.shiftRight=l.prototype.shiftRight=u.prototype.shiftRight,u.prototype.not=function(){return this.negate().prev()},c.prototype.not=l.prototype.not=u.prototype.not,u.prototype.and=function(e){return R(this,e,(function(e,t){return e&t}))},c.prototype.and=l.prototype.and=u.prototype.and,u.prototype.or=function(e){return R(this,e,(function(e,t){return e|t}))},c.prototype.or=l.prototype.or=u.prototype.or,u.prototype.xor=function(e){return R(this,e,(function(e,t){return e^t}))},c.prototype.xor=l.prototype.xor=u.prototype.xor;var $=1<<30;function B(e){var t=e.value,r="number"==typeof t?t|$:"bigint"==typeof t?t|BigInt($):t[0]+t[1]*n|1073758208;return r&-r}function U(e,n){if(n.compareTo(e)<=0){var r=U(e,n.square(n)),o=r.p,i=r.e,s=o.multiply(n);return s.compareTo(e)<=0?{p:s,e:2*i+1}:{p:o,e:2*i}}return{p:t(1),e:0}}function _(e,t){return e=Q(e),t=Q(t),e.greater(t)?e:t}function J(e,t){return e=Q(e),t=Q(t),e.lesser(t)?e:t}function F(e,t){if(e=Q(e).abs(),t=Q(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n,r,o=a[1];e.isEven()&&t.isEven();)n=J(B(e),B(t)),e=e.divide(n),t=t.divide(n),o=o.multiply(n);for(;e.isEven();)e=e.divide(B(e));do{for(;t.isEven();)t=t.divide(B(t));e.greater(t)&&(r=t,t=e,e=r),t=t.subtract(e)}while(!t.isZero());return o.isUnit()?e:e.multiply(o)}u.prototype.bitLength=function(){var e=this;return e.compareTo(t(0))<0&&(e=e.negate().subtract(t(1))),0===e.compareTo(t(0))?t(0):t(U(e,t(2)).e).add(t(1))},c.prototype.bitLength=l.prototype.bitLength=u.prototype.bitLength;var H=function(e,t,n,r){n=n||i,e=String(e),r||(e=e.toLowerCase(),n=n.toLowerCase());var o,s=e.length,a=Math.abs(t),u={};for(o=0;o=a)){if("1"===p&&1===a)continue;throw new Error(p+" is not a valid digit in base "+t+".")}}t=Q(t);var l=[],c="-"===e[0];for(o=c?1:0;o"!==e[o]&&o=0;r--)o=o.add(e[r].times(i)),i=i.times(t);return n?o.negate():o}function z(e,n){if((n=t(n)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(n.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var o=!1;if(e.isNegative()&&n.isPositive()&&(o=!0,e=e.abs()),n.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:o};for(var i,s=[],a=e;a.isNegative()||a.compareAbs(n)>=0;){i=a.divmod(n),a=i.quotient;var u=i.remainder;u.isNegative()&&(u=n.minus(u).abs(),a=a.next()),s.push(u.toJSNumber())}return s.push(a.toJSNumber()),{value:s.reverse(),isNegative:o}}function V(e,t,n){var r=z(e,t);return(r.isNegative?"-":"")+r.value.map((function(e){return function(e,t){return e<(t=t||i).length?t[e]:"<"+e+">"}(e,n)})).join("")}function W(e){if(p(+e)){var t=+e;if(t===v(t))return s?new c(BigInt(t)):new l(t);throw new Error("Invalid integer: "+e)}var n="-"===e[0];n&&(e=e.slice(1));var r=e.split(/e/i);if(r.length>2)throw new Error("Invalid integer: "+r.join("e"));if(2===r.length){var o=r[1];if("+"===o[0]&&(o=o.slice(1)),(o=+o)!==v(o)||!p(o))throw new Error("Invalid integer: "+o+" is not a valid exponent.");var i=r[0],a=i.indexOf(".");if(a>=0&&(o-=i.length-a-1,i=i.slice(0,a)+i.slice(a+1)),o<0)throw new Error("Cannot include negative exponent part for integers");e=i+=new Array(o+1).join("0")}if(!/^([0-9][0-9]*)$/.test(e))throw new Error("Invalid integer: "+e);if(s)return new c(BigInt(n?"-"+e:e));for(var h=[],d=e.length,g=d-7;d>0;)h.push(+e.slice(g,d)),(g-=7)<0&&(g=0),d-=7;return f(h),new u(h,n)}function Q(e){return"number"==typeof e?function(e){if(s)return new c(BigInt(e));if(p(e)){if(e!==v(e))throw new Error(e+" is not an integer.");return new l(e)}return W(e.toString())}(e):"string"==typeof e?W(e):"bigint"==typeof e?new c(e):e}u.prototype.toArray=function(e){return z(this,e)},l.prototype.toArray=function(e){return z(this,e)},c.prototype.toArray=function(e){return z(this,e)},u.prototype.toString=function(t,n){if(t===e&&(t=10),10!==t)return V(this,t,n);for(var r,o=this.value,i=o.length,s=String(o[--i]);--i>=0;)r=String(o[i]),s+="0000000".slice(r.length)+r;return(this.sign?"-":"")+s},l.prototype.toString=function(t,n){return t===e&&(t=10),10!=t?V(this,t,n):String(this.value)},c.prototype.toString=l.prototype.toString,c.prototype.toJSON=u.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},u.prototype.valueOf=function(){return parseInt(this.toString(),10)},u.prototype.toJSNumber=u.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,c.prototype.valueOf=c.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var X=0;X<1e3;X++)a[X]=Q(X),X>0&&(a[-X]=Q(-X));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=_,a.min=J,a.gcd=F,a.lcm=function(e,t){return e=Q(e).abs(),t=Q(t).abs(),e.divide(F(e,t)).multiply(t)},a.isInstance=function(e){return e instanceof u||e instanceof l||e instanceof c},a.randBetween=function(e,t,r){e=Q(e),t=Q(t);var o=r||Math.random,i=J(e,t),s=_(e,t).subtract(i).add(1);if(s.isSmall)return i.add(Math.floor(o()*s));for(var u=z(s,n).value,l=[],c=!0,p=0;p=0&&t>0;)n[--t]=e.charCodeAt(r--);for(n[--t]=0;t>2;)n[--t]=255;n[--t]=2,n[--t]=0;let o=this.a2hex(n);return u(o,16)}pkcs1unpad2(e){let t=e.toString(16);t.length%2!=0&&(t="0"+t);let n=this.hex2a(t),r=1;for(;0!==n.charCodeAt(r);)r++;return n.slice(r+1)}encrypt(e){let t=this.pkcs1pad2(e,128).modPow(this.e,this.n).toString(16);for(;t.length<256;)t="0"+t;return t}decrypt(e){let t=[],n=0;for(;n=0?iu;o=u>=0?++i:--i)p.push(e[o]^n[o%r]);for(o=s=l=a,c=t;l<=c?sc;o=l<=c?++s:--s)p.push(e[o]^n[(o-a)%r]);return p}getkey(e,t){let n;return null!=t?(()=>{let r,o,i;for(i=[],n=r=0,o=e;o>=0?ro;n=o>=0?++r:--r)i.push(t[n]+this.kts[e*n]&255^this.kts[e*(e-1-n)]);return i})():12===e?this.keyL.slice(0):this.keyS.slice(0)}asymEncode(e,t){let n,r,o,i,s;for(o=117,s="",n=r=0,i=Math.floor((t+o-1)/o);i>=0?ri;n=i>=0?++r:--r)s+=this.rsa.encrypt(this.bytesToString(e.slice(n*o,Math.min((n+1)*o,t))));return window.btoa(this.rsa.hex2a(s))}asymDecode(e,t){let n,r,o,i,s;for(o=128,s="",n=r=0,i=Math.floor((t+o-1)/o);i>=0?ri;n=i>=0?++r:--r)s+=this.rsa.decrypt(this.bytesToString(e.slice(n*o,Math.min((n+1)*o,t))));return this.stringToBytes(s)}symEncode(e,t,n,r){let o,i,s;return o=this.getkey(4,n),i=this.getkey(12,r),s=this.xor115Enc(e,t,o,4),s.reverse(),s=this.xor115Enc(s,t,i,12),s}symDecode(e,t,n,r){let o,i,s;return o=this.getkey(4,n),i=this.getkey(12,r),s=this.xor115Enc(e,t,i,12),s.reverse(),s=this.xor115Enc(s,t,o,4),s}bytesToString(e){let t,n,r,o;for(o="",n=0,r=e.length;n=0?nr;t=r>=0?++n:--n)o.push(e.charCodeAt(t));return o}encode(e,t){const n=this.stringToBytes(s(`!@###@#${t}DFDR@#@#`));let r=this.stringToBytes(e);return r=this.symEncode(r,r.length,n,null),r=n.slice(0,16).concat(r),{data:this.asymEncode(r,r.length),key:n}}decode(e,t){let n=this.stringToBytes(window.atob(e));return n=this.asymDecode(n,n.length),this.bytesToString(this.symDecode(n.slice(16),n.length-16,t,n.slice(0,16)))}};(new class extends class{constructor(e){this.listParameter=e,this.fileDownloadInfo=[],this.currentTaskId=0,this.completedCount=0,this.folders=[],this.files={}}start(e=300,t){this.interval=e,this.done=t,this.currentTaskId=(new Date).getTime(),this.getNextFile(this.currentTaskId)}reset(){this.fileDownloadInfo=[],this.currentTaskId=0,this.folders=[],this.files={},this.completedCount=0}addFolder(e){this.folders.push(e)}addFile(e){this.files[e.pick_code]=e}getNextFile(e){if(e===this.currentTaskId)if(0!==this.folders.length){this.completedCount++,t.showToast(`正在获取文件列表... ${this.completedCount}/${this.completedCount+this.folders.length-1}`,"inf");const n=this.folders.pop();this.listParameter.search.cid=n.cate_id,t.sendToBackground("fetch",{url:`${this.listParameter.url}${t.objectToQueryString(this.listParameter.search)}`,options:this.listParameter.options},(t=>{setTimeout((()=>this.getNextFile(e)),this.interval);const r=n.path+t.path[t.path.length-1].name+"/";t.data.forEach((e=>{e.sha?this.files[e.pc]={path:r,isdir:!1,sha1:e.sha,pick_code:e.pc}:this.folders.push({cate_id:e.cid,path:r})}))}))}else 0!==this.files.length?(t.showToast("正在获取下载地址...","inf"),this.getFiles(this.files).then((()=>{this.done(this.fileDownloadInfo)}))):(t.showToast("一个文件都没有哦...","war"),this.reset())}getFiles(e){throw new Error("subclass should implement this method!")}}{constructor(){super({search:{aid:1,limit:1e3,show_dir:1,cid:""},url:`${location.protocol}//webapi.115.com/files?`,options:{credentials:"include",method:"GET"}}),this.mode="RPC",this.rpcURL="http://localhost:6800/jsonrpc",this.iframe=document.querySelector('iframe[rel="wangpan"]')}initialize(){return this.context=document.querySelector('iframe[rel="wangpan"]').contentDocument,n.init(),n.addMenu(this.context.querySelector("#js_top_panel_box"),"afterbegin"),this.context.querySelector(".right-tvf").style.display="block",this.addMenuButtonEventListener(),n.addContextMenuRPCSectionWithCallback((()=>{this.addContextMenuEventListener()})),t.showToast("初始化成功!","inf"),this}startListen(){const e=e=>{e.forEach((e=>{e.isdir?this.addFolder(e):this.addFile(e)})),this.start(t.getConfigData("interval"),(e=>{if("RPC"===this.mode&&t.aria2RPCMode(this.rpcURL,e),"TXT"===this.mode&&(t.aria2TXTMode(e),document.querySelector("#textMenu").classList.add("open-o")),"OPEN"===this.mode)for(const t of e)window.open("https://115.com/?ct=play&ac=location&pickcode="+t.pickcode)}))};window.addEventListener("message",(n=>{const r=n.data.type;if(r&&("selected"===r||"hovered"===r)){this.reset();const r=n.data.data;if(0===r.length)return void t.showToast("请选择一下你要保存的文件哦","war");e(r)}})),this.iframe.addEventListener("load",(()=>{this.initialize(),window.postMessage({type:"refresh"},location.origin)}))}addMenuButtonEventListener(){this.context.querySelector("#aria2List").addEventListener("click",(e=>{const t=e.target.dataset.url;t&&(this.rpcURL=t,this.getSelected(),this.mode="RPC"),"aria2Text"===e.target.id&&(this.getSelected(),this.mode="TXT"),"batchOpen"===e.target.id&&(this.getSelected(),this.mode="OPEN")}))}addContextMenuEventListener(){this.context.querySelector("#more-menu-rpc-section").addEventListener("click",(e=>{const t=e.target.dataset.url;t&&(this.rpcURL=t,this.getHovered(),this.mode="RPC")}))}getSelected(){window.postMessage({type:"getSelected"},location.origin)}getHovered(){window.postMessage({type:"getHovered"},location.origin)}getFile(e){return t.getConfigData("vip")?this.getFileFromProAPI(e):this.getFileFromWebAPI(e)}getFileFromWebAPI(e){const n={credentials:"include",method:"GET"};return new Promise((r=>{t.sendToBackground("fetch",{url:`${location.protocol}//webapi.115.com/files/download?pickcode=${e}`,options:n},(n=>{if(n.file_url){const e=n.file_url.match(/.*115.com(\/.*\/)/)[1];t.requestCookies([{path:e}]).then((e=>{n.cookies=e,r(n)}))}else t.showToast("无法获取下载地址!","err"),r(e)}))}))}getFileFromProAPI(e){const n=Date.now(),r=Math.floor(n/1e3),{data:o,key:i}=c.encode(JSON.stringify({pickcode:e}),r),s={headers:{"Content-Type":"application/x-www-form-urlencoded"},credentials:"include",method:"POST",body:`data=${encodeURIComponent(o)}`};return new Promise((n=>{t.sendToBackground("fetch",{url:`https://proapi.115.com/app/chrome/downurl?t=${r}`,options:s},(r=>{if(r.state){const o=JSON.parse(c.decode(r.data,i)),s=Object.values(o).pop();s.pickcode=s.pick_code,s.file_url=s.url.url,s.file_url?t.requestCookies([{url:"https://proapi.115.com/",name:"acw_tc"}]).then((e=>{s.cookies=e,n(s)})):(t.showToast("无法获取下载地址!","err"),n(e))}else n(e)}))}))}getFiles(e){const t=Object.keys(e).map((e=>this.getFile(e)));return new Promise((n=>{Promise.all(t).then((t=>{t.forEach((t=>{this.isObject(t)?this.fileDownloadInfo.push({name:e[t.pickcode].path+t.file_name,link:t.file_url,size:t.file_size,sha1:e[t.pickcode].sha1,cookies:t.cookies,pickcode:t.pickcode}):console.log(e[t])})),n()}))}))}isObject(e){return null!==e&&"object"==typeof e}}).initialize().startListen()}(); --------------------------------------------------------------------------------