// ==UserScript== // @name Anime1.me 下載器 // @namespace https://blog.maple3142.net/ // @version 0.2 // @description 下載Anime1.me網站上的動漫 // @author maple3142 // @match https://anime1.me/* // @match https://p.anime1.me/* // @require https://code.jquery.com/jquery-3.2.1.min.js // @noframes // @grant none // @downloadURL none // ==/UserScript== (function($) { 'use strict'; //觸發下載(firefox需要同源才能正常觸發,否則會當成普通連結打開) function download(url,filename){ const a=document.createElement('a'); a.href=url; a.download=filename; document.body.appendChild(a); a.click(); a.remove(); } const loc=window.location; if(loc.hostname==='p.anime1.me'){//如果是下載頁面 //取得資料 const video=jwplayer().getPlaylist()[0]; if(!video)return; const sources=video.sources; const title=video.title; const videomap=Object.assign(...sources.map(src=>({[src.label]: src.file})));//Object.assign({'HD': 'hd video url'},{'SD': 'sd video url'},something...) //詢問要下載的畫質 const askmsg=`輸入要下載的畫質名稱:(${sources.map(src=>src.label).join(',')})`; const type=prompt(askmsg); //如果畫質存在 if(type in videomap){ download(videomap[type],`${title}.mp4`); } } else{//其他頁面 if($('.acpwd-pass').length){ //如果需要密碼就自動登入 $('.acpwd-pass').get(0).value='anime1.me'; //目前的密碼(2017-12-03T14:15:37.823Z) $('.acpwd-submit').get(0).click(); return; } //找到每個影片 const $articles=$('article'); for(let art of $articles){ const $title=$(art).find('.entry-title'); const url=$(art).find('iframe').attr('src'); if(!url)continue;//如果沒有影片 $title.append($('