// ==UserScript== // @name anime1.me收藏番剧(交互优化+去广告版) // @namespace http://tampermonkey.net/ // @version 0.3.1 // @license MPL-2.0 // @description 添加了收藏番剧功能(来自@c4r的脚本)优化了UI和交互 // @author c4r feat.皮蛋萌 // @match *://anime1.me/* // @grant none // @require https://code.jquery.com/jquery-latest.js // @downloadURL none // ==/UserScript== (function () { 'use strict'; function getPlaylist() { let strPlaylist = localStorage.getItem('anime1Playlist') if (strPlaylist === undefined || strPlaylist === null) { strPlaylist = '' } else {} let arryPlaylist = new Array() let slotList = strPlaylist.split('\r\n').slice(0, -1) slotList.forEach(item => { let titlePos = item.indexOf("title :") let urlPos = item.indexOf('url :') if (titlePos < 0 || urlPos < 0) {} else { let title = item.slice(7, urlPos - 1) let url = item.slice(urlPos + 5) arryPlaylist.push({ 'title': title, 'url': url }) } }) return arryPlaylist } function delSub(title, url) { let strPlaylist = localStorage.getItem('anime1Playlist') let str = 'title :' + title + ' url :' + url + '\r\n' // console.log(strPlaylist) // console.log('---') // console.log(str) // console.log('include : ', strPlaylist.includes(str)) if (strPlaylist.includes(str)) { strPlaylist = strPlaylist.replace(str, '') console.log(strPlaylist) localStorage.setItem('anime1Playlist', strPlaylist) } } function addPlaylist(title, url) { let strPlaylist = localStorage.getItem('anime1Playlist') if (strPlaylist === undefined || strPlaylist === null) { strPlaylist = '' } else { } if (strPlaylist.includes('title :' + title + ' url :' + url)) { delSub(title, url) $('li[title="'+title+'"]').remove() $("#menu-subscribe").attr('value',"订阅"); } else { strPlaylist = strPlaylist + 'title :' + title + ' url :' + url + '\r\n' localStorage.setItem('anime1Playlist', strPlaylist) // location.reload() $('#subscribe > ul').append('
  • \ [x] \ ' + title + '\
  • ') $("#menu-subscribe").attr('value',"退订"); } } function showPlaylist() { $('

    收藏列表

    ').insertBefore( $('#recent-posts-6') ) let arrayPlaylist = getPlaylist() arrayPlaylist.forEach(item => { $('#subscribe > ul').append('
  • \ [x] \ ' + item.title + '\
  • ') }) } $(document).ready(function () { //移除广告 $('#execphp-6').remove() $('#anime-bottom').remove() let title = $('footer span.cat-links:eq(0) > a').text() let url = $('footer span.cat-links:eq(0) > a').attr('href') let strPlaylist = localStorage.getItem('anime1Playlist') let value = '' if (strPlaylist.includes('title :' + title + ' url :' + url)) { value = '退订' }else{value = '订阅'} if ($('footer span.cat-links').length > 0) { // 添加订阅按钮 $('').insertBefore($('#recent-posts-6')) $("#menu-subscribe").on("click", () => { // console.log(title, url) addPlaylist(title, url) }); } showPlaylist() $(document).on('click', 'a[unsubscribed]', (event) => { // // console.log(event.target) let title = $(event.target).attr('name') let url = $(event.target).attr('url') // console.log('删除 : ', title , url) if(title == $('footer span.cat-links:eq(0) > a').text()){$("#menu-subscribe").attr('value',"订阅");} delSub(title, url) // location.reload() $(event.target).closest('li').remove() }) }) })();