From 276f78f771fedfff11a052debaad42e9febdf601 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 01:08:58 +0800 Subject: [PATCH 0001/1027] matching new url and better logic --- MicroMagazinSurveyNovel.user.js | 50 ++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/MicroMagazinSurveyNovel.user.js b/MicroMagazinSurveyNovel.user.js index e2ef3e1..5962530 100644 --- a/MicroMagazinSurveyNovel.user.js +++ b/MicroMagazinSurveyNovel.user.js @@ -1,32 +1,48 @@ // ==UserScript== // @name アンケートノベルプリント // @namespace https://github.com/jc3213/userscript -// @version 3 +// @version 4 // @description マイクロマガジン社のアンケート協力者向けの書き下ろしノベルプリントヘルパーです // @author jc3213 -// @match *://micromagazine.net/me/qu/*_thanks.html +// @match *://micromagazine.co.jp/me/qu/*_thanks*.html // ==/UserScript== -var css = document.createElement('link'); -css.rel = 'stylesheet'; -css.type = 'text/css'; -css.href = 'style_a.css'; -document.head.appendChild(css); - var button = document.createElement('div'); button.id = 'print_helper'; button.style.cssText = 'position: absolute; left: 25%; top: 5%; z-lindex: 3213; background-color: white; color: black; padding: 5px; border: 1px solid #e9e9e9; cursor: pointer;'; button.innerHTML = 'プリント仕様'; button.addEventListener('click', (event) => { - var content = document.getElementById('books') || document.getElementById('contents_c'); - content.style.border = 'none'; - content.style.margin = '0px'; - content.style.margin = '0px'; - document.body.replaceWith(content); + var book = document.getElementById('books') || document.getElementById('contents_c'); + book.id = 'books'; + book.style.cssText = 'border: none; margin: 0px; padding: 0px'; + + document.body.replaceWith(book); + + var css = document.createElement('link'); + css.rel = 'stylesheet'; + css.type = 'text/css'; + css.href = 'style_a.css'; + book.appendChild(css); - var header = content.children[0]; - if (['p', 'br'].includes(header.tagName.toLowerCase())) { - header.remove(); - } + var footer; + var content = book.querySelectorAll('p'); + content.forEach((item, index) => { + if (!item.children[0]) { + return; + } + if (index > footer) { + item.remove(); + } + else if (item.children[0].tagName === 'BR') { + if (index === 0) { + item.remove(); + } + item.replaceWith(item.children[0]); + } + else if (item.children[0].tagName === 'A') { + item.remove(); + footer = index; + } + }); }); document.body.appendChild(button); From ad4365230ab2e64536402ec43b0aa2fbac7edf0b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 01:14:40 +0800 Subject: [PATCH 0002/1027] minor logc change --- MicroMagazinSurveyNovel.user.js | 60 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/MicroMagazinSurveyNovel.user.js b/MicroMagazinSurveyNovel.user.js index 5962530..9ca3bb2 100644 --- a/MicroMagazinSurveyNovel.user.js +++ b/MicroMagazinSurveyNovel.user.js @@ -7,42 +7,42 @@ // @match *://micromagazine.co.jp/me/qu/*_thanks*.html // ==/UserScript== +var book = document.getElementById('books') || document.getElementById('contents_c'); +book.id = 'books'; + +var css = document.createElement('link'); +css.rel = 'stylesheet'; +css.type = 'text/css'; +css.href = 'style_a.css'; +book.appendChild(css); + +var footer; +var content = book.querySelectorAll('p'); +content.forEach((item, index) => { + if (!item.children[0]) { + return; + } + if (index > footer) { + item.remove(); + } + else if (item.children[0].tagName === 'BR') { + if (index === 0) { + item.remove(); + } + item.replaceWith(item.children[0]); + } + else if (item.children[0].tagName === 'A') { + item.remove(); + footer = index; + } +}); + var button = document.createElement('div'); button.id = 'print_helper'; button.style.cssText = 'position: absolute; left: 25%; top: 5%; z-lindex: 3213; background-color: white; color: black; padding: 5px; border: 1px solid #e9e9e9; cursor: pointer;'; button.innerHTML = 'プリント仕様'; button.addEventListener('click', (event) => { - var book = document.getElementById('books') || document.getElementById('contents_c'); - book.id = 'books'; book.style.cssText = 'border: none; margin: 0px; padding: 0px'; - document.body.replaceWith(book); - - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'style_a.css'; - book.appendChild(css); - - var footer; - var content = book.querySelectorAll('p'); - content.forEach((item, index) => { - if (!item.children[0]) { - return; - } - if (index > footer) { - item.remove(); - } - else if (item.children[0].tagName === 'BR') { - if (index === 0) { - item.remove(); - } - item.replaceWith(item.children[0]); - } - else if (item.children[0].tagName === 'A') { - item.remove(); - footer = index; - } - }); }); document.body.appendChild(button); From 32395b810920cdbf800c075de43e88ea620d69e2 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 09:43:22 +0800 Subject: [PATCH 0003/1027] changed banlist to another variable with Object --- BilibiliLiveRoomFilter.user.js | 58 ++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 1761649..db27e73 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -1,18 +1,29 @@ // ==UserScript== -// @name bilibili 直播间屏蔽工具 -// @namespace https://github.com/jc3213/userscript -// @version 12.1 -// @description try to take over the world! -// @author jc3213 -// @match *://live.bilibili.com/* -// @grant GM_getValue -// @grant GM_setValue +// @name 哔哩哔哩直播间屏蔽工具 +// @namespace https://github.com/jc3213/userscript +// @version 13 +// @description 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出列表等…… +// @author jc3213 +// @match *://live.bilibili.com/* +// @grant GM_getValue +// @grant GM_setValue +// @grant GM_deleteValue // @noframes // ==/UserScript== 'use strict'; var ban_id = GM_getValue('id', []); var ban_liver = GM_getValue('liver', []); +var banned = GM_getValue('banned', {}); + +if (Object.keys(banned).length === 0 && ban_id.length !== 0) { + if (confirm('因版本变动,旧版本的列表将不再兼容,请点击确认进行导出,点击取消刷新后还会弹出本对话框。')) { + ban_id.forEach((item, index) => { banned[item] = ban_liver[index] }); + GM_deleteValue('id'); + GM_deleteValue('liver'); + GM_setValue('banned', banned); + } +} var css = document.createElement('style'); css.innerHTML = '.fancybutton {background-color: #23ade5; color: #ffffff; padding: 5px 10px; border-radius: 3px; font-size: 14px; text-align: center; user-select: none; cursor: pointer;}\ @@ -44,7 +55,7 @@ if (player) { } }); player.querySelector('a.room-owner-username').after(block); - if (ban_id.includes(id)) { + if (banned[id]) { if (!confirm('【 ' + liver + ' 】的直播间已被屏蔽,是否继续观看?')) { open(area, '_self'); } @@ -63,29 +74,29 @@ list.addEventListener('DOMNodeInserted', (event) => { }); function addBanlist(id, liver) { - if (!ban_id.includes(id)) { - ban_id.push(id); - ban_liver.push(liver); + if (!banned[id]) { + banned[id] = liver; makeBanlist(id, liver); } } function removeBanlist(id) { - var index = ban_id.indexOf(id); - ban_id = [...ban_id.slice(0, index), ...ban_id.slice(index + 1)]; - ban_liver = [...ban_liver.slice(0, index), ...ban_liver.slice(index + 1)]; - ban_list.querySelector('#banned_' + id).remove(); + if (banned[id]) { + delete banned[id]; + ban_list.querySelector('#banned_' + id).remove(); + } } function saveBanlist() { - GM_setValue('id', ban_id); - GM_setValue('liver', ban_liver); - list.querySelectorAll('li').forEach(item => banLiveRoom(item)); + GM_setValue('banned', banned); + if (list) { + list.querySelectorAll('li').forEach(item => banLiveRoom(item)); + } } function banLiveRoom(element) { var id = element.querySelector('a').href.match(/\d+/)[0]; - element.style.display = ban_id.includes(id) ? 'none' : 'block'; + element.style.display = banned[id] ? 'none' : 'block'; return id; } @@ -161,7 +172,7 @@ ban_list.className = 'fancylist'; ban_list.style.cssText = 'display: none; left: 242px;' manager.after(ban_list); -ban_id.forEach((item, index) => makeBanlist(item, ban_liver[index])); +Object.entries(banned).forEach(item => makeBanlist(item[0], item[1])); function makeBanlist(id, liver) { var box = document.createElement('div'); @@ -216,7 +227,7 @@ save.innerHTML = '导出列表'; save.className = 'fancybutton'; save.addEventListener('click', (event) => { if (confirm('确定要导出当前屏蔽列表吗?')) { - var list = ban_id.map((item, index) => item + ', ' + ban_liver[index]).join('\n'); + var list = Object.entries(banned).map(item => item[0] + ', ' + item[1]).join('\n'); blobToFile(new Blob([list], {type: 'text/plain'}), 'bilibili直播间屏蔽列表'); } }); @@ -228,8 +239,7 @@ clear.className = 'fancybutton'; clear.addEventListener('click', (event) => { if (confirm('确定要清空当前屏蔽列表吗?')) { ban_list.innerHTML = ban_head; - ban_id = []; - ban_liver = []; + banned = {}; saveBanlist(); } }); From 64bdc0ade9aa7b18b0a7f5fc06e8cd881a3a797d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 10:00:02 +0800 Subject: [PATCH 0004/1027] better description on confirm --- BilibiliLiveRoomFilter.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index db27e73..e5e1ffa 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -17,7 +17,7 @@ var ban_liver = GM_getValue('liver', []); var banned = GM_getValue('banned', {}); if (Object.keys(banned).length === 0 && ban_id.length !== 0) { - if (confirm('因版本变动,旧版本的列表将不再兼容,请点击确认进行导出,点击取消刷新后还会弹出本对话框。')) { + if (confirm('因版本变动,旧版本的列表将不再兼容!\b点击确认后将自动转换!\n点击取消刷新后还会弹出本对话框!')) { ban_id.forEach((item, index) => { banned[item] = ban_liver[index] }); GM_deleteValue('id'); GM_deleteValue('liver'); From 64824cfb67271710d1df766e0d89564a80339fc2 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 10:00:24 +0800 Subject: [PATCH 0005/1027] typo --- BilibiliLiveRoomFilter.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index e5e1ffa..9037e18 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -17,7 +17,7 @@ var ban_liver = GM_getValue('liver', []); var banned = GM_getValue('banned', {}); if (Object.keys(banned).length === 0 && ban_id.length !== 0) { - if (confirm('因版本变动,旧版本的列表将不再兼容!\b点击确认后将自动转换!\n点击取消刷新后还会弹出本对话框!')) { + if (confirm('因版本变动,旧版本的列表将不再兼容!\n点击确认后将自动转换!\n点击取消刷新后还会弹出本对话框!')) { ban_id.forEach((item, index) => { banned[item] = ban_liver[index] }); GM_deleteValue('id'); GM_deleteValue('liver'); From 0d0699ffc175e65ff31b394a67530a6b202d5fbd Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 13:36:25 +0800 Subject: [PATCH 0006/1027] minor update --- TategakiPDFManager.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TategakiPDFManager.user.js b/TategakiPDFManager.user.js index 5a09315..2815fd0 100644 --- a/TategakiPDFManager.user.js +++ b/TategakiPDFManager.user.js @@ -36,12 +36,12 @@ css.innerHTML = '.manager-button {background-color: #FFF; padding: 5px; border: .manager-shelf, .manager-logs {overflow-y: scroll; height: 552px;}\ .manager-shelf div:nth-child(2n+1) {background-color: #DDD;}\ .manager-shelf span {height: 40px; text-align: center; vertical-align: middle; display: inline-block; padding: 5px;}\ -.manager-shelf input {width: 50px;}\ +.manager-shelf input {width: 70px;}\ .manager-shelf span:nth-child(1) {width: 80px; margin-top: 15px; cursor: pointer;}\ -.manager-shelf span:nth-child(2) {width: 460px; overflow-y: hidden; text-align: left; cursor: pointer;}\ +.manager-shelf span:nth-child(2) {width: 525px; overflow-y: hidden; text-align: left; cursor: pointer;}\ .manager-shelf span:nth-child(3) {width: 90px; margin-top: 15px;}\ -.manager-shelf span:nth-child(4) {width: 180px; overflow-y: hidden; cursor: pointer;}\ -.manager-shelf div:nth-child(1) span {height: 20px; overflow-y: hidden; text-align: center; margin: 0px; cursor: default;}\ +.manager-shelf span:nth-child(4) {width: 110px; overflow-y: hidden; cursor: pointer;}\ +.manager-shelf div:nth-child(1) span {height: 20px; overflow-y: hidden; text-align: center; margin: 0px; cursor: default; border: 1px solid #fff;}\ .manager-shelf div:nth-child(n+2) span:hover {filter: opacity(60%);}\ .manager-shelf div:nth-child(n+2) span:active {filter: opacity(30%);}\ .fancylog {font-size: 16px;}\ @@ -179,7 +179,7 @@ function fancyTableItem(ncode, book) { makeFancyItem(box, {'tag': 'span', 'title': '小説のウェブページを開きます', 'html': book.title, 'click': (event) => openNovelPage(ncode, book.title)}); var item3 = makeFancyItem(box, {'tag': 'span', 'title': '更新間隔を' + book.next + '日に設定します'}); makeFancyItem(item3, {'tag': 'input', 'change': (event) => updatePeriodHandler(event, item3, ncode, book.title), 'attr': {'id': ncode + '-next', 'value': book.next}}); - makeFancyItem(box, {'tag': 'span', 'title': '縦書きPDFの更新をチェックします', 'html': new Date(book.last), 'click': (event) => updateTategakiPDF(ncode, book.title), 'attr': {'id': ncode + '-update'}}); + makeFancyItem(box, {'tag': 'span', 'title': '縦書きPDFの更新をチェックします', 'html': new Date(book.last).toLocaleString('ja'), 'click': (event) => updateTategakiPDF(ncode, book.title), 'attr': {'id': ncode + '-update'}}); } function makeFancyItem(box, props) { var tag = document.createElement(props.tag); From 116be327346f4ca6020d4056ad80230590519477 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 13:47:44 +0800 Subject: [PATCH 0007/1027] better layout --- TategakiPDFManager.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TategakiPDFManager.user.js b/TategakiPDFManager.user.js index 2815fd0..f05916f 100644 --- a/TategakiPDFManager.user.js +++ b/TategakiPDFManager.user.js @@ -30,16 +30,16 @@ css.innerHTML = '.manager-button {background-color: #FFF; padding: 5px; border: .manager-button:hover {filter: opacity(60%);}\ .manager-button:active {filter: opacity(30%);}\ .manager-checked {padding: 4px; border: 2px inset #00F;}\ -.manager-container {position: fixed; top: 47px; left: calc((100% - 880px) / 2); background-color: #FFF; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ +.manager-container {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #FFF; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ .manager-container > span, .manager-container > input {margin-left: 5px;}\ .manager-container > div {padding: 5px; margin-top: 5px;}\ .manager-shelf, .manager-logs {overflow-y: scroll; height: 552px;}\ .manager-shelf div:nth-child(2n+1) {background-color: #DDD;}\ -.manager-shelf span {height: 40px; text-align: center; vertical-align: middle; display: inline-block; padding: 5px;}\ +.manager-shelf span {height: 100%; text-align: center; vertical-align: middle; display: inline-block; padding: 5px;}\ .manager-shelf input {width: 70px;}\ -.manager-shelf span:nth-child(1) {width: 80px; margin-top: 15px; cursor: pointer;}\ +.manager-shelf span:nth-child(1) {width: 80px; cursor: pointer;}\ .manager-shelf span:nth-child(2) {width: 525px; overflow-y: hidden; text-align: left; cursor: pointer;}\ -.manager-shelf span:nth-child(3) {width: 90px; margin-top: 15px;}\ +.manager-shelf span:nth-child(3) {width: 90px;}\ .manager-shelf span:nth-child(4) {width: 110px; overflow-y: hidden; cursor: pointer;}\ .manager-shelf div:nth-child(1) span {height: 20px; overflow-y: hidden; text-align: center; margin: 0px; cursor: default; border: 1px solid #fff;}\ .manager-shelf div:nth-child(n+2) span:hover {filter: opacity(60%);}\ From b3843337e6dc1114cb98ab45180a44f7679df4ce Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 22:02:45 +0800 Subject: [PATCH 0008/1027] onerror for bad network --- TategakiPDFManager.user.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/TategakiPDFManager.user.js b/TategakiPDFManager.user.js index f05916f..22123f9 100644 --- a/TategakiPDFManager.user.js +++ b/TategakiPDFManager.user.js @@ -92,13 +92,17 @@ function validateNcode(ncode) { return validNcodeResponse(ncode, validate[ncode]); } validate[ncode] = '検証中'; - myFancyLog('', 'Nコード' + ncode, 'を検証しています、しばらくお待ちください!', true) + myFancyLog('', 'Nコード' + ncode, 'を検証しています、しばらくお待ちください!', true); GM_xmlhttpRequest({ url: 'https://ncode.syosetu.com/' + ncode, method: 'GET', onload: (details) => { validate[ncode] = details.responseXML.title; validNcodeResponse(ncode, validate[ncode]); + }, + onerror: (error) => { + myFancyLog('', 'Nコード' + ncode, 'の検証は失敗しました!', true); + delete validate[ncode]; } }); } @@ -297,6 +301,11 @@ function batchDownloadPreHandler(ncode) { else { downloadPDFHandler(ncode); } + }, + onerror: (error) => { + myFancyPopup(ncode, bookmark[ncode].title, 'のダウンロードは失敗しました!'); + delete download[ncode]; + session[ncode] = '失敗'; } }); } From a46fe8f7fab0437b7fcba033c0eab97be1c01d04 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 22:04:48 +0800 Subject: [PATCH 0009/1027] reverted onerror --- TategakiPDFManager.user.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/TategakiPDFManager.user.js b/TategakiPDFManager.user.js index 22123f9..5b7fe40 100644 --- a/TategakiPDFManager.user.js +++ b/TategakiPDFManager.user.js @@ -99,10 +99,6 @@ function validateNcode(ncode) { onload: (details) => { validate[ncode] = details.responseXML.title; validNcodeResponse(ncode, validate[ncode]); - }, - onerror: (error) => { - myFancyLog('', 'Nコード' + ncode, 'の検証は失敗しました!', true); - delete validate[ncode]; } }); } @@ -301,11 +297,6 @@ function batchDownloadPreHandler(ncode) { else { downloadPDFHandler(ncode); } - }, - onerror: (error) => { - myFancyPopup(ncode, bookmark[ncode].title, 'のダウンロードは失敗しました!'); - delete download[ncode]; - session[ncode] = '失敗'; } }); } From 15f5fef235244e5b044cb70a0bd91185c57e878d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 6 Dec 2020 22:06:50 +0800 Subject: [PATCH 0010/1027] oops, time format --- TategakiPDFManager.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TategakiPDFManager.user.js b/TategakiPDFManager.user.js index 5b7fe40..022ac8f 100644 --- a/TategakiPDFManager.user.js +++ b/TategakiPDFManager.user.js @@ -289,7 +289,7 @@ function batchDownloadPreHandler(ncode) { a.download = bookmark[ncode].title; a.click(); bookmark[ncode].last = novelist.now; - document.getElementById(ncode + '-update').innerHTML = new Date(novelist.now); + document.getElementById(ncode + '-update').innerHTML = new Date(novelist.now).toLocaleString('ja'); myFancyLog(ncode, bookmark[ncode].title, 'のダウンロードは完了しました!', true); delete download[ncode]; session[ncode] = '完了'; From a64ff89b930da66d2d7e8f969387ec90c8d6d1a1 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 17:01:47 +0800 Subject: [PATCH 0011/1027] optimized code size and performance --- BilibiliLiveRoomFilter.user.js | 153 +++++++++++++-------------------- 1 file changed, 62 insertions(+), 91 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 9037e18..b2130b5 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 13 +// @version 14 // @description 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出列表等…… // @author jc3213 // @match *://live.bilibili.com/* @@ -27,15 +27,18 @@ if (Object.keys(banned).length === 0 && ban_id.length !== 0) { var css = document.createElement('style'); css.innerHTML = '.fancybutton {background-color: #23ade5; color: #ffffff; padding: 5px 10px; border-radius: 3px; font-size: 14px; text-align: center; user-select: none; cursor: pointer;}\ +.fancybutton:hover {filter: opacity(60%);}\ +.fancybutton:active {filter: opacity(30%);}\ +.fancymenu {display: block; margin-bottom: 10px;}\ +.fancymenu .fancybutton:nth-child(n+2) {margin-left: 5px;}\ .fancylist {background-color: #fff; font-size: 14px; width: 270px; height: 360px; overflow-y: auto; border: 1px solid #23ade5; z-index: 999999; position: absolute;}\ -.fancylist div:nth-child(n+2) span:nth-child(2) {background-color: #ddd;}\ .fancylist span:nth-child(1) {width: calc(50% - 50px);}\ .fancylist span:nth-child(2) {width: calc(50% + 25px);}\ -.fancylist > .fancybutton {margin: 0px 3px 0px 2px;}\ +.fancylist textarea {resize: none; height: calc(100% - 40px); width: calc(100% - 8px); font-size: 14px; padding: 3px;}\ .fancyitem {display: inline-block; padding: 5px; text-align: center; border: 1px solid #fff;}\ .fancytitle {background-color: #000; color: #fff;}\ -.fancybutton:hover {filter: opacity(60%);}\ -.fancybutton:active {filter: opacity(30%);}\ +.fancybody span:nth-child(2) {background-color: #ddd;}\ +.fancyfooter .fancybutton {margin: 0px 3px 0px 2px;}\ div.sort-box > span:nth-child(n+2), div.room-info-down-row > span {margin-left: 5px}'; document.head.appendChild(css); @@ -113,39 +116,32 @@ function addMenuToLiveRoom(element) { var name = element.querySelector('span.room-title').innerHTML; var preview = element.querySelector('div.cover-ctnr').style['background-image'].match(/https:\/\/[^\@]+/)[0]; - var block = document.createElement('span'); - block.innerHTML = '屏蔽直播间'; - block.className = 'fancybutton'; - block.addEventListener('click', (event) => { - event.preventDefault(); - if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { - addBanlist(id, liver); - saveBanlist(); + var container = document.createElement('span'); + container.className = 'fancymenu'; + container.innerHTML = '屏蔽直播间下载封面' + container.addEventListener('click', (event) => { + if (event.target.id === 'block_liveroom') { + event.preventDefault(); + if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { + addBanlist(id, liver); + saveBanlist(); + } } - }); - - var download = document.createElement('span'); - download.innerHTML = '下载封面'; - download.className = 'fancybutton'; - download.style.cssText = 'margin-left: 5px;'; - download.addEventListener('click', (event) => { - event.preventDefault(); - if (confirm('确定要下载直播《' + name + '》的封面吗?')) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', preview, true); - xhr.responseType = 'blob'; - xhr.onload = () => blobToFile(xhr.response, id + '_' + name); - xhr.send(); + else if (event.target.id === 'download_preview') { + event.preventDefault(); + if (confirm('确定要下载直播《' + name + '》的封面吗?')) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', preview, true); + xhr.responseType = 'blob'; + xhr.onload = () => blobToFile(xhr.response, id + '_' + name); + xhr.send(); + } } }); element.addEventListener('DOMNodeInserted', (event) => { if (event.target.tagName === 'DIV' && event.target.classList.contains('hover-panel-wrapper')) { - var container = document.createElement('span'); - container.style.cssText = 'display: block; margin-bottom: 10px;'; event.target.prepend(container); - container.appendChild(block); - container.appendChild(download); } }); } @@ -166,8 +162,7 @@ manager.addEventListener('click', (event) => { document.querySelector('div.sort-box').appendChild(manager); var ban_list = document.createElement('div'); -var ban_head = '
直播间主播
'; -ban_list.innerHTML = ban_head; +ban_list.innerHTML = '
直播间主播
'; ban_list.className = 'fancylist'; ban_list.style.cssText = 'display: none; left: 242px;' manager.after(ban_list); @@ -175,72 +170,48 @@ manager.after(ban_list); Object.entries(banned).forEach(item => makeBanlist(item[0], item[1])); function makeBanlist(id, liver) { - var box = document.createElement('div'); - box.id = 'banned_' + id; - var ban_id = document.createElement('span'); - ban_id.innerHTML = id; - ban_id.className = 'fancyitem fancybutton'; - ban_id.addEventListener('click', (event) => { - if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { - removeBanlist(id); - saveBanlist(); + var ban = document.createElement('div'); + ban.id = 'banned_' + id; + ban.innerHTML = '' + id + '' + liver + ''; + ban.addEventListener('click', (event) => { + if (event.target.id === 'remove_liveroom') { + if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { + removeBanlist(id); + saveBanlist(); + } } }); - var ban_liver = document.createElement('span'); - ban_liver.innerHTML = liver; - ban_liver.className = 'fancyitem'; - ban_list.appendChild(box); - box.appendChild(ban_id); - box.appendChild(ban_liver); + document.getElementById('banned_liveroom').appendChild(ban); } var batch_box = document.createElement('div'); +batch_box.innerHTML = '
批量屏蔽导出列表清空列表
' batch_box.className = 'fancylist'; batch_box.style.cssText = 'display: none;'; -manager.after(batch_box); - -var ban_box = document.createElement('textarea'); -ban_box.style.cssText = 'resize: none; height: calc(100% - 40px); width: calc(100% - 8px); font-size: 14px; padding: 3px;'; -batch_box.appendChild(ban_box); - -var submit = document.createElement('span'); -submit.innerHTML = '批量屏蔽'; -submit.className = 'fancybutton'; - -submit.addEventListener('click', (event) => { - if (confirm('确定要屏蔽列表中的直播间吗?')) { - var pattern = ban_box.value.split('\n'); - pattern.forEach(item => { - var rule = item.match(/^(\d+)[\s\/\.\@\#\$\,\/\\]+([^\s\/\.\@\#\$\,\/\\]+)/); - if (rule) { - addBanlist(rule[1], rule[2]); - } - }); - saveBanlist(); - ban_box.value = ''; +batch_box.addEventListener('click', (event) => { + if (event.target.id === 'batch_ban') { + if (confirm('确定要屏蔽列表中的直播间吗?')) { + var batch = document.getElementById('batch_list'); + var pattern = batch.value.match(/^(\d+)[\s\/\.\@\#\$\,\/\\]+([^\s\/\.\@\#\$\,\/\\]+)/mg).forEach(item => { + var rule = item.split(/[\s\/\.\@\#\$\,\/\\]+/); + addBanlist(rule[0], rule[1]); + }); + saveBanlist(); + batch.value = ''; + } } -}); -batch_box.appendChild(submit); - -var save = document.createElement('span'); -save.innerHTML = '导出列表'; -save.className = 'fancybutton'; -save.addEventListener('click', (event) => { - if (confirm('确定要导出当前屏蔽列表吗?')) { - var list = Object.entries(banned).map(item => item[0] + ', ' + item[1]).join('\n'); - blobToFile(new Blob([list], {type: 'text/plain'}), 'bilibili直播间屏蔽列表'); + else if (event.target.id === 'batch_save') { + if (confirm('确定要导出当前屏蔽列表吗?')) { + var list = Object.entries(banned).map(item => item[0] + ', ' + item[1]).join('\n'); + blobToFile(new Blob([list], {type: 'text/plain'}), 'bilibili直播间屏蔽列表'); + } } -}); -batch_box.appendChild(save); - -var clear = document.createElement('span'); -clear.innerHTML = '清空列表'; -clear.className = 'fancybutton'; -clear.addEventListener('click', (event) => { - if (confirm('确定要清空当前屏蔽列表吗?')) { - ban_list.innerHTML = ban_head; - banned = {}; - saveBanlist(); + else if (event.target.id === 'batch_clear') { + if (confirm('确定要清空当前屏蔽列表吗?')) { + document.getElementById('banned_liveroom').innerHTML = ''; + banned = {}; + saveBanlist(); + } } }); -batch_box.appendChild(clear); +manager.after(batch_box); From bf9f342b3a25e1246dfd28ebf87563230d20687d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 19:58:57 +0800 Subject: [PATCH 0012/1027] better logic on make ui --- TategakiPDFManager.user.js | 232 +++++++++++++++---------------------- 1 file changed, 93 insertions(+), 139 deletions(-) diff --git a/TategakiPDFManager.user.js b/TategakiPDFManager.user.js index 022ac8f..23475f1 100644 --- a/TategakiPDFManager.user.js +++ b/TategakiPDFManager.user.js @@ -26,26 +26,25 @@ var scheduler = GM_getValue('scheduler', novelist.now); // UI作成関連 var css = document.createElement('style'); -css.innerHTML = '.manager-button {background-color: #FFF; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; display: inline-block; font-weight: bold; cursor: pointer;}\ +css.innerHTML = '.manager-button {background-color: #fff; text-align: center; vertical-align: middle; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; display: inline-block; cursor: pointer; font-weight: bold;}\ .manager-button:hover {filter: opacity(60%);}\ .manager-button:active {filter: opacity(30%);}\ .manager-checked {padding: 4px; border: 2px inset #00F;}\ -.manager-container {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #FFF; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ -.manager-container > span, .manager-container > input {margin-left: 5px;}\ -.manager-container > div {padding: 5px; margin-top: 5px;}\ +.manager-container {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ +.manager-menu :not(:first-child) {margin-left: 5px;}\ +.manager-menu input {height: 20px;}\ +.manager-container > div:nth-child(n+2) {margin-top: 5px;}\ .manager-shelf, .manager-logs {overflow-y: scroll; height: 552px;}\ .manager-shelf div:nth-child(2n+1) {background-color: #DDD;}\ -.manager-shelf span {height: 100%; text-align: center; vertical-align: middle; display: inline-block; padding: 5px;}\ -.manager-shelf input {width: 70px;}\ -.manager-shelf span:nth-child(1) {width: 80px; cursor: pointer;}\ -.manager-shelf span:nth-child(2) {width: 525px; overflow-y: hidden; text-align: left; cursor: pointer;}\ -.manager-shelf span:nth-child(3) {width: 90px;}\ -.manager-shelf span:nth-child(4) {width: 110px; overflow-y: hidden; cursor: pointer;}\ +.manager-shelf span { background-color: inherit; display: inline-block; padding: 5px; border: none; padding: 5px; font-weight: normal;}\ +.manager-shelf span:nth-child(1) {width: 100px;}\ +.manager-shelf span:nth-child(2) {width: 515px; text-align: left;}\ +.manager-shelf span:nth-child(3) {width: 100px;}\ +.manager-shelf input {width: 70px; padding: 5px;}\ +.manager-shelf div:nth-child(1) span:nth-child(4) {width: 100px;}\ +.manager-shelf div:nth-child(n+2) span:nth-child(4) {width: 90px; margin-right: 2px;}\ .manager-shelf div:nth-child(1) span {height: 20px; overflow-y: hidden; text-align: center; margin: 0px; cursor: default; border: 1px solid #fff;}\ -.manager-shelf div:nth-child(n+2) span:hover {filter: opacity(60%);}\ -.manager-shelf div:nth-child(n+2) span:active {filter: opacity(30%);}\ -.fancylog {font-size: 16px;}\ -.notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000;}'; +.notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff;}'; document.head.appendChild(css); var manager = document.createElement('span'); @@ -64,25 +63,48 @@ manager.addEventListener('click', (event) => { document.getElementById('head_nav').appendChild(manager); var container = document.createElement('div'); +container.innerHTML = '
NCODE登録\ +\ +NCODE一括更新\ +ログ表示
\ +
NCODE小説タイトル更新間隔ダウンロード
\ +'; container.className = 'manager-container'; container.style.cssText = 'display: none;'; -document.body.appendChild(container); - -var subscribe = document.createElement('span'); -subscribe.innerHTML = 'NCODE登録'; -subscribe.className = 'manager-button'; -subscribe.addEventListener('click', (event) => { - if (bookmark[novelist.myncode]) { - myFancyPopup(novelist.myncode, bookmark[novelist.myncode].title, 'は既に書庫に登録しています!'); +container.addEventListener('click', (event) => { + if (event.target.id === 'subscribe-ncode') { + if (bookmark[novelist.myncode]) { + myFancyPopup(novelist.myncode, bookmark[novelist.myncode].title, 'は既に書庫に登録しています!'); + } + else if (novelist.myncode === novelist.ncode) { + subscribeNcode(novelist.ncode, novelist.title); + } + else { + validateNcode(novelist.myncode); + } } - else if (novelist.myncode === novelist.ncode) { - subscribeNcode(novelist.ncode, novelist.title); + else if (event.target.id === 'download-all-ncode') { + bookmarkSyncPreHandler(); } - else { - validateNcode(novelist.myncode); + else if (event.target.id === 'display-fancylog') { + if (event.target.classList.contains('manager-checked')) { + container.querySelector('div.manager-logs').style.display = 'none'; + container.querySelector('div.manager-shelf').style.display = 'block'; + } + else { + container.querySelector('div.manager-logs').style.display = 'block'; + container.querySelector('div.manager-shelf').style.display = 'none'; + } + event.target.classList.toggle('manager-checked'); + } +}); +container.addEventListener('change', (event) => { + if (event.target.id === 'bookmark-ncode') { + novelist.myncode = event.target.value || novelist.ncode; } }); -container.appendChild(subscribe); +document.body.appendChild(container); + // NCODE検証&登録 function validateNcode(ncode) { if (validate[ncode] === '検証中') { @@ -121,112 +143,46 @@ function subscribeNcode(ncode, title) { myFancyLog(ncode, title, 'は書庫に登録しました!', true); } -var ncodeBox = document.createElement('input'); -ncodeBox.style.cssText = 'padding: 6px; font-size: 16px;'; -ncodeBox.addEventListener('change', (event) => { novelist.myncode = event.target.value || novelist.ncode; }); -container.appendChild(ncodeBox); - -var update = document.createElement('span'); -update.innerHTML = 'NCODE一括更新'; -update.className = 'manager-button'; -update.addEventListener('click', bookmarkSyncPreHandler); -container.appendChild(update); - -var openlog = document.createElement('span'); -openlog.innerHTML = 'ログ表示'; -openlog.className = 'manager-button'; -openlog.addEventListener('click', (event) => { - if (openlog.classList.contains('manager-checked')) { - fancylog.style.display = 'none'; - shelf.style.display = 'block'; - } - else { - fancylog.style.display = 'block'; - shelf.style.display = 'none'; - } - openlog.classList.toggle('manager-checked'); -}); -container.appendChild(openlog); - -var fancylog = document.createElement('div'); -fancylog.className = 'manager-logs'; -fancylog.style.cssText = 'display: none;'; -container.appendChild(fancylog); - -var shelf = document.createElement('div'); -shelf.className = 'manager-shelf'; -container.appendChild(shelf); - -var head = document.createElement('div'); -head.style.cssText = 'background-color: #000; color: #FFF;'; -head.innerHTML = 'NCODE小説タイトル更新間隔ダウンロード'; -shelf.appendChild(head); - // ブックマーク表記生成 -Object.entries(bookmark).forEach(item => fancyTablePreHandler(...item)); -function fancyTablePreHandler(ncode, book) { - if (document.getElementById(ncode)) { - document.getElementById(ncode + '-next').value = book.next; - document.getElementById(ncode + '-update').innerHTML = book.last; - } - else { - fancyTableItem(ncode, book) - } -} +Object.entries(bookmark).forEach(item => fancyTableItem(...item)); function fancyTableItem(ncode, book) { - var box = makeFancyItem(shelf, {'tag': 'div', 'attr': {'id': ncode}}); - makeFancyItem(box, {'tag': 'span', 'title': 'NCODEを書庫から削除します', 'html': ncode, 'click': (event) => removeNcodeFromLibrary(ncode, book.title)}); - makeFancyItem(box, {'tag': 'span', 'title': '小説のウェブページを開きます', 'html': book.title, 'click': (event) => openNovelPage(ncode, book.title)}); - var item3 = makeFancyItem(box, {'tag': 'span', 'title': '更新間隔を' + book.next + '日に設定します'}); - makeFancyItem(item3, {'tag': 'input', 'change': (event) => updatePeriodHandler(event, item3, ncode, book.title), 'attr': {'id': ncode + '-next', 'value': book.next}}); - makeFancyItem(box, {'tag': 'span', 'title': '縦書きPDFの更新をチェックします', 'html': new Date(book.last).toLocaleString('ja'), 'click': (event) => updateTategakiPDF(ncode, book.title), 'attr': {'id': ncode + '-update'}}); -} -function makeFancyItem(box, props) { - var tag = document.createElement(props.tag); - if (props.title) { - tag.title = props.title; - } - if (props.html) { - tag.innerHTML = props.html; - } - if (props.click) { - tag.addEventListener('click', props.click); - } - if (props.change) { - tag.addEventListener('change', props.change); - } - if (props.attr) { - Object.entries(props.attr).forEach(item => { tag[item[0]] = item[1] }); - } - box.appendChild(tag); - return tag; -} -// ブックマーク事件処理 -function removeNcodeFromLibrary(ncode, title) { - if (confirm('【 ' + title + ' 】を書庫から削除しますか?')) { - document.getElementById(ncode).remove(); - delete bookmark[ncode]; - GM_setValue('bookmark', bookmark); - myFancyLog(ncode, title, 'は書庫から削除しました!', true); - } -} -function openNovelPage(ncode, title) { - if (confirm('小説【 ' + title + ' 】を開きますか?')) { - open('https://ncode.syosetu.com/' + ncode + '/', '_blank') - } -} -function updatePeriodHandler(event, node, ncode, title) { - var value = event.target.value.match(/\d+/)[0]; - node.title = '更新間隔を' + value + '日に設定します'; - bookmark[ncode].next = value; - GM_setValue('bookmark', bookmark); - myFancyPopup(ncode, title, 'は ' + value + ' 日置きに更新します!'); -} -function updateTategakiPDF(ncode, title) { - if (confirm(title + ' をダウンロードしますか?')) { - updateObserver(1); - batchDownloadPreHandler(ncode, title); - } + var mybook = document.createElement('div'); + mybook.id = ncode; + mybook.innerHTML = '' + ncode + '\ + ' + book.title + '\ + \ + ' + new Date(book.last).toLocaleString('ja') + ''; + mybook.addEventListener('click', (event) => { + if (event.target.id === 'unsubscribe-ncode') { + if (confirm('【 ' + book.title + ' 】を書庫から削除しますか?')) { + mybook.remove(); + delete bookmark[ncode]; + GM_setValue('bookmark', bookmark); + myFancyLog(ncode, book.title, 'は書庫から削除しました!', true); + } + } + else if (event.target.id === 'navigate-ncode') { + if (confirm('小説【 ' + book.title + ' 】を開きますか?')) { + open('https://ncode.syosetu.com/' + ncode + '/', '_blank') + } + } + else if (event.target.id === 'update-ncode') { + if (confirm(book.title + ' をダウンロードしますか?')) { + updateObserver(1); + batchDownloadPreHandler(ncode, book.title); + } + } + }); + mybook.addEventListener('change', (event) => { + if (event.target.id === 'interval-ncode') { + var value = event.target.value.match(/\d+/)[0]; + event.target.parentNode.title = '更新間隔を' + value + '日に設定します'; + bookmark[ncode].next = value; + GM_setValue('bookmark', bookmark); + myFancyPopup(ncode, book.title, 'は ' + value + ' 日置きに更新します!'); + } + }); + container.querySelector('div.manager-shelf').appendChild(mybook); } // PDF自動更新関連 @@ -289,7 +245,7 @@ function batchDownloadPreHandler(ncode) { a.download = bookmark[ncode].title; a.click(); bookmark[ncode].last = novelist.now; - document.getElementById(ncode + '-update').innerHTML = new Date(novelist.now).toLocaleString('ja'); + container.querySelector('#' + ncode + ' > #update-ncode').innerHTML = new Date(novelist.now).toLocaleString('ja'); myFancyLog(ncode, bookmark[ncode].title, 'のダウンロードは完了しました!', true); delete download[ncode]; session[ncode] = '完了'; @@ -317,18 +273,16 @@ function downloadPDFHandler(ncode) { function myFancyLog(ncode, title, result, popup) { var html = myFancyNcode(ncode, title) + ' ' + result + ''; var log = document.createElement('p'); - log.className = 'fancylog'; log.innerHTML = html; - fancylog.prepend(log); + container.querySelector('div.manager-logs').prepend(log); if (popup === true) { myFancyPopup(ncode, title, result); } } function myFancyPopup(ncode, title, result) { - var html = myFancyNcode(ncode, title) + ' ' + result + ''; var popup = document.createElement('div'); - popup.innerHTML = html; - popup.className = 'notification fancylog manager-container'; + popup.innerHTML = myFancyNcode(ncode, title) + ' ' + result + ''; + popup.className = 'notification manager-container'; popup.style.height = 'fit-content'; popup.addEventListener('click', (event) => removePopup(popup)); document.body.appendChild(popup); @@ -348,9 +302,9 @@ function myFancyNcode(ncode, title) { return ''; } function alignFancyPopup() { - document.querySelectorAll('.notification').forEach((element, index) => { + document.querySelectorAll('div.notification').forEach((element, index) => { element.style.top = (element.offsetHeight + 5) * index + 10 + 'px'; - element.style.left = (screen.availWidth - element.offsetWidth) / 2 + 'px'; + element.style.left = (innerWidth - element.offsetWidth) / 2 + 'px'; }); } function removePopup(popup) { From 32cafb559f2c9d750b4bfa638ac99711252990fd Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 20:03:27 +0800 Subject: [PATCH 0013/1027] changed variable --- SpeedRunHelper.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 53dba80..9f14d34 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -76,15 +76,15 @@ function createRecordWindow(id, content, top, left) { container.style.cssText = 'position: fixed; top: ' + top / 2 + 'px; left: ' + left / 2 + 'px; z-index: 3213; width: 850px; height: 500px;'; document.body.appendChild(container); - var box = document.createElement('div'); - box.style.cssText = 'background-color: #000; height: 25px; width: 100%; text-align: right; user-select: none;'; - container.appendChild(box); + var menu = document.createElement('div'); + menu.style.cssText = 'background-color: #000; height: 25px; width: 100%; text-align: right; user-select: none;'; + container.appendChild(menu); var close = document.createElement('span'); close.className = 'speedrun-menu'; close.addEventListener('click', (event) => container.remove()) close.innerHTML = '✖'; - box.appendChild(close); + menu.appendChild(close); container.appendChild(content); } From 3440685ed1e7bf6becee0ae2d45c64d4277033d9 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 21:35:18 +0800 Subject: [PATCH 0014/1027] simplified the codes with better logic --- RawMangaAssistant.user.js | 381 ++++++++++++++++---------------------- 1 file changed, 159 insertions(+), 222 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index b7589f0..9fcfaf0 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -18,7 +18,6 @@ // @connect * // @grant GM_getValue // @grant GM_setValue -// @grant GM_addValueChangeListener // @grant GM_xmlhttpRequest // @grant GM_webRequest // @webRequest {"selector": "*.adtrue.com/*", "action": "cancel"} @@ -70,13 +69,20 @@ var urls = []; var save = []; var aria2 = []; var fail = []; -var download; var observer; var images; var watching; var mousedown; var moving = false; -var position = GM_getValue('position', {top: screen.availHeight * 0.3, left: screen.availWidth * 0.15}); +var position = GM_getValue('position', {top: innerHeight * 0.3, left: innerWidth * 0.15}); +var values = { + lazy: GM_getValue('lazy', false), + context: GM_getValue('context', true) +} +var rpc = { + server: GM_getValue('server', 'http://localhost:6800/jsonrpc'), + secret: GM_getValue('secret', '') +}; var offset = {}; var lazyload; var warning; @@ -101,13 +107,13 @@ var messages = { nokey: 'Aria2 RPC secret token is invalid' }, secret: 'Secret token updated, reloading page in 5 seconds', - btop: { + gotop: { label: 'Back to Top', }, lazy: { label: 'Preload All Images' }, - menu: { + context: { label: 'Context Menu Mode' }, extract: { @@ -136,13 +142,13 @@ var messages = { nokey: 'Aria2 RPC 密钥不正确' }, secret: '密钥已更新,5秒后自动刷新页面', - btop: { + gotop: { label: '回到顶部', }, lazy: { label: '预加载所有图像', }, - menu: { + context: { label: '右键菜单模式', }, extract: { @@ -159,8 +165,8 @@ var i18n = messages[navigator.language] || messages['en-US']; // Supported sites var mangas = { 'loveheaven.net': { - chapter: /\/read-(.+)-raw-chapter-(.+)\.html/, - folder: () => {return chapter[1].replace(/-manga/, '') + '\\' + chapter[2]}, + chapter: /\/read-(.+)-chapter-(.+)\.html/, + folder: () => {return chapter[1].replace(/-manga(-raw)?/, '') + '\\' + chapter[2]}, selector: 'img.chapter-img', ads: ['h3', 'br:nth-child(-n+3)', 'div.float-ck', 'div.chapter-content center'], shortcut: {prev: 'a[class="btn btn-info prev"]', next: 'a[class="btn btn-info next"]'} @@ -172,8 +178,8 @@ var mangas = { lazyload: 'data-original' }, 'batoscan.net': { - chapter: /\/read-(.+)-raw-chapter-(.+)\.html/, - folder: () => {return chapter[1].replace(/-manga/, '') + '\\' + chapter[2]}, + chapter: /\/read-(.+)-chapter-(.+)\.html/, + folder: () => {return chapter[1].replace(/-manga(-raw)?/, '') + '\\' + chapter[2]}, selector: 'img[class="chapter-img"]', lazyload: 'data-original', }, @@ -209,7 +215,7 @@ document.head.appendChild(css); var button = document.createElement('span'); button.id = 'assistant_button'; button.innerHTML = '🖱️'; -button.className = 'menuOverlay menuContainer'; +button.className = 'menuOverlay assistantMenu'; button.draggable = true; button.style.cssText = 'top: ' + position.top + 'px; left: ' + position.left + 'px; text-align: center; padding-top: 10px; width: 42px; height: 42px;'; document.body.appendChild(button); @@ -228,15 +234,12 @@ document.addEventListener('dragstart', (event) => { document.addEventListener('dragend', (event) => { position.top += event.clientY - offset.top; position.left += event.clientX - offset.left; - GM_setValue('position', position); -}); -GM_addValueChangeListener('position', (name, old_value, new_value, remote) => movingIconAndContainer(new_value)); -function movingIconAndContainer(position) { button.style.top = position.top + 'px'; button.style.left = position.left + 'px'; container.style.top = button.offsetTop + 'px'; container.style.left = button.offsetLeft + button.offsetWidth + 'px'; -} + GM_setValue('position', position); +}); document.addEventListener('click', (event) => { if (event.target.id === 'assistant_aria2_server' || event.target.id === 'assistant_aria2_secret') { return; @@ -255,127 +258,125 @@ document.addEventListener('click', (event) => { }); // Create menuitems -var downBox = document.createElement('div'); -downBox.id = 'assistant_down'; -downBox.className = 'menuContainer'; -downBox.style.display = 'none'; -container.appendChild(downBox); - -var downMenu = { - save: { - icon: '💾', - click: () => { - download = []; - save.forEach((item, index) => { - GM_xmlhttpRequest({ - method: 'GET', - url: item[0], - responseType: 'blob', - onload: (details) => { - var a = document.createElement('a'); - a.href = URL.createObjectURL(details.response); - a.download = item[1]; - a.click(); - download.push(index); - if (download.length === images.length) { - notification('save', 'done'); - download = []; - } - }, - onerror: () => notification('save', 'error', item[0]) - }); - }); - } - }, - copy: { - icon: '📄', - click: () => { - navigator.clipboard.writeText(urls.join('\n')); - notification('copy', 'done'); - } - }, - aria2: { - icon: '🖅', - click: () => { - downMenu.aria2.handler({ - method: 'aria2.getGlobalOption' - }, (details) => { - if (details.status === 200) { - if (details.response.includes('Unauthorized')) { - notification('aria2', 'nokey'); - } - else { - var dir = details.response.match(/"dir":"([^"]+)"/)[1] + '\\' + watching.folder(); - var aria2 = save.map((item, index) => downMenu.aria2.handler({ - method: 'aria2.addUri', - options: [[item[0]], {out: item[1], dir: dir, header: header}] - }, () => { - if (index === images.length - 1) { - notification('aria2', 'done'); - } - })); - } - } - else { - notification('aria2', 'norpc'); - } - }, (error) => { - notification('aria2', 'norpc'); - }); - }, - handler: (property, onload, onerror) => { +var downMenu = document.createElement('div'); +downMenu.innerHTML = '
💾' + i18n.save.label + '
\ +
📄' + i18n.copy.label + '
\ +
🖅' + i18n.aria2.label + '
'; +downMenu.className = 'menuContainer'; +downMenu.style.display = 'none'; +downMenu.addEventListener('click', (event) => { + if (event.target.id === 'assistant_save') { + save.forEach((item, index) => { GM_xmlhttpRequest({ - url: document.getElementById('assistant_aria2_server').value, - method: 'POST', - data: JSON.stringify({ - id: '', - jsonrpc: '2.0', - method: property.method, - params: ['token:' + document.getElementById('assistant_aria2_secret').value].concat(property.options) - }), - onload: onload, - onerror: onerror + method: 'GET', + url: item[0], + responseType: 'blob', + onload: (details) => { + var a = document.createElement('a'); + a.href = URL.createObjectURL(details.response); + a.download = item[1]; + a.click(); + if (index === images.length - 1) { + notification('save', 'done'); + } + }, + onerror: () => notification('save', 'error', item[0]) }); - }, - event: { - contextmenu: (event) => { - event.preventDefault(); - if (aria2Box.style.display === 'block') { - aria2Box.style.display = 'none'; + }); + } + else if (event.target.id === 'assistant_copy') { + navigator.clipboard.writeText(urls.join('\n')); + notification('copy', 'done'); + } + else if (event.target.id === 'assistant_aria2') { + aria2RequestHandler({ + method: 'aria2.getGlobalOption' + }, (details) => { + if (details.status === 200) { + if (details.response.includes('Unauthorized')) { + notification('aria2', 'nokey'); } else { - aria2Box.style.display = 'block'; + var dir = details.response.match(/"dir":"([^"]+)"/)[1] + '\\' + watching.folder(); + var aria2 = save.map((item, index) => aria2RequestHandler({ + method: 'aria2.addUri', + options: [[item[0]], {out: item[1], dir: dir, header: header}] + }, () => { + if (index === images.length - 1) { + notification('aria2', 'done'); + } + })); } } + else { + notification('aria2', 'norpc'); + } + }, (error) => { + notification('aria2', 'norpc'); + }); + } +}); +downMenu.addEventListener('contextmenu', (event) => { + if (event.target.id === 'assistant_aria2') { + event.preventDefault(); + if (aria2Menu.style.display === 'block') { + aria2Menu.style.display = 'none'; + } + else { + aria2Menu.style.display = 'block'; } } -}; -Object.entries(downMenu).forEach((item) => downBox.appendChild(click_menu_item(...item))); +}); +container.appendChild(downMenu); -var clickBox = document.createElement('div'); -clickBox.id = 'assistant_click'; -clickBox.className = 'menuContainer'; -container.appendChild(clickBox); +var aria2Menu = document.createElement('div'); +aria2Menu.innerHTML = '\ +'; +aria2Menu.className = 'menuContainer'; +aria2Menu.style.cssText = 'position: absolute; display: none; top: 80px; left: 190px;'; +aria2Menu.addEventListener('change', (event) => { + var id = event.target.id.replace('assistant_aria2_', ''); + rpc[id] = event.target.value; + GM_setValue(id, rpc[id]); +}); +container.appendChild(aria2Menu); -var clickMenu = { - btop: { - icon: '⬆️', - click: () => { - document.documentElement.scrollTop = 0; - } - } -}; -Object.entries(clickMenu).forEach((item) => clickBox.appendChild(click_menu_item(...item))); +function aria2RequestHandler(request, onload, onerror) { + GM_xmlhttpRequest({ + url: rpc.server, + method: 'POST', + data: JSON.stringify({ + id: '', + jsonrpc: '2.0', + method: request.method, + params: ['token:' + rpc.secret].concat(request.options) + }), + onload: onload, + onerror: onerror + }); +} -var switchBox = document.createElement('div'); -switchBox.id = 'assistant_switch'; -switchBox.className = 'menuContainer'; -container.appendChild(switchBox); +var clickMenu = document.createElement('div'); +clickMenu.innerHTML = '
⬆️' + i18n.gotop.label + '
'; +clickMenu.className = 'menuContainer'; +clickMenu.addEventListener('click', (event) => { + if (event.target.id === 'assistant_gotop') { + document.documentElement.scrollTop = 0; + } +}); +container.appendChild(clickMenu); -var switchMenu = { - lazy: { - value: GM_getValue('lazy', false), - on: () => { +var switchMenu = document.createElement('div'); +switchMenu.innerHTML = '
' + switchIcon(values.lazy) + '' + i18n.lazy.label + '
\ +
' + switchIcon(values.context) + '' + i18n.context.label + '
'; +switchMenu.addEventListener('click', (event) => { + var id = event.target.id.replace('assistant_', ''); + var menu = switchMenu.querySelector('#' + event.target.id); + values[id] = !values[id]; + menu.firstElementChild.innerHTML = switchIcon(values[id]); + GM_setValue(id, values[id]); + if (event.target.id === 'assistant_lazy') { + if (values[id]) { if (!images || !watching.lazyload) { return; } @@ -385,112 +386,48 @@ var switchMenu = { clearInterval(lazyload); } }, 100); - }, - off: () => { + } + else { clearInterval(lazyload); } - }, - menu: { - value: GM_getValue('menu', true), - on: () => { + } + else if (event.target.id === 'assistant_context') { + if (values[id]) { button.style.display = 'none'; - document.addEventListener('contextmenu', switchMenu.menu.handler); - }, - off: () => { - document.removeEventListener('contextmenu', switchMenu.menu.handler); + document.addEventListener('contextmenu', contextHandler); + } + else { + document.removeEventListener('contextmenu', contextHandler); button.style.display = 'block'; container.style.top = button.offsetTop + 'px'; container.style.left = button.offsetLeft + button.offsetWidth + 'px'; - }, - handler: (event) => { - if (event.target.id === 'assistant_menu_aria2' || event.shiftKey) { - if (container.style.display = 'block') { - container.style.display = 'none'; - } - return; - } - event.preventDefault(); - container.style.top = event.clientY + 'px'; - container.style.left = event.clientX + 'px'; - container.style.display = 'block'; } - }, -} -Object.entries(switchMenu).forEach((item) => switchBox.appendChild(switch_menu_item(...item))); - -var aria2Box = document.createElement('div'); -aria2Box.id = 'assistant_aria2'; -aria2Box.className = 'menuContainer'; -aria2Box.style.cssText = 'position: absolute; display: none; top: ' + Object.keys(downMenu).indexOf('aria2') * 40 + 'px; left: 190px;'; -container.appendChild(aria2Box); - -var aria2Menu = { - // Aria2 menu items - server: { - value: GM_getValue('server', 'http://localhost:6800/jsonrpc') - }, - secret: { - type: 'password', - value: GM_getValue('secret', '') } -}; -Object.entries(aria2Menu).forEach((item) => aria2Box.appendChild(input_menu_item(...item))); +}); +switchMenu.className = 'menuContainer'; +container.appendChild(switchMenu); +Object.keys(values).forEach(id => { + if (values[id]) { + values[id] = !values[id]; + document.getElementById('assistant_' + id).click(); + } +}); -// UI maker callback handler -function iconic_menu_item(name, props) { - var menu = document.createElement('span'); - menu.id = 'assistant_menu_' + name; - menu.className = 'assistantMenu'; - var icon = document.createElement('span'); - icon.className = 'assistantIcon'; - icon.innerHTML = props.icon || ''; - var label = document.createTextNode(i18n[name].label || name); - menu.appendChild(icon); - menu.appendChild(label); - return menu; -} -function click_menu_item(name, props) { - var menu = iconic_menu_item(name, props); - menu.addEventListener('click', props.click); - if (props.event) { - Object.entries(props.event).forEach((item) => menu.addEventListener(...item)); +function contextHandler(event) { + if (event.target.id === 'assistant_aria2' || event.shiftKey) { + return; } - return menu; + event.preventDefault(); + container.style.top = event.clientY + 'px'; + container.style.left = event.clientX + 'px'; + container.style.display = 'block'; } -function switch_menu_item(name, props) { - var menu = iconic_menu_item(name, props); - menu.value = props.value; - menu.addEventListener('click', () => GM_setValue(name, !menu.value)); - switch_item_handler(menu, props); - GM_addValueChangeListener(name, (name, old_value, new_value, remote) => { - menu.value = new_value; - switch_item_handler(menu, props); - }); - return menu; -} -function switch_item_handler(menu, props) { - if (menu.value) { - menu.firstElementChild.innerHTML = '✅'; - props.on(); - } - else { - menu.firstElementChild.innerHTML = ''; - props.off(); + +function switchIcon(value) { + if (value) { + return '✅'; } -} -function input_menu_item(name, props) { - var menu = document.createElement('input'); - menu.id = 'assistant_aria2_' + name; - menu.className = 'assistantMenu menuAria2Item'; - menu.value = props.value; - menu.setAttribute('type', props.type); - menu.addEventListener('change', (event) => GM_setValue(name, event.target.value)); - menu.addEventListener('focus', (event) => event.target.setAttribute('type', 'text')); - menu.addEventListener('blur', (event) => event.target.setAttribute('type', props.type)); - GM_addValueChangeListener(name, (name, old_value, new_value, remote) => { - menu.value = new_value; - }); - return menu; + return ''; } // Extract images data @@ -529,7 +466,7 @@ function extractImage(lazyload) { warning.remove(); clearInterval(observer); if (fail.length === 0) { - document.getElementById('assistant_down').style.display = 'block'; + downMenu.style.display = 'block'; notification('extract', 'done'); } else { @@ -619,6 +556,6 @@ function notification(action, status, url) { function align_notification() { document.querySelectorAll('#assistant_caution').forEach((element, index) => { element.style.top = index * (element.offsetHeight + 5) + 10 + 'px'; - element.style.left = (screen.availWidth - element.offsetWidth) / 2 + 'px'; + element.style.left = (innerWidth - element.offsetWidth) / 2 + 'px'; }); } From 308a7d35eec38cdc7d9d2fd480c5c77025caf0e1 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 22:16:42 +0800 Subject: [PATCH 0015/1027] oops, much better logic --- RawMangaAssistant.user.js | 104 +++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 9fcfaf0..d994993 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -75,14 +75,6 @@ var watching; var mousedown; var moving = false; var position = GM_getValue('position', {top: innerHeight * 0.3, left: innerWidth * 0.15}); -var values = { - lazy: GM_getValue('lazy', false), - context: GM_getValue('context', true) -} -var rpc = { - server: GM_getValue('server', 'http://localhost:6800/jsonrpc'), - secret: GM_getValue('secret', '') -}; var offset = {}; var lazyload; var warning; @@ -329,27 +321,31 @@ downMenu.addEventListener('contextmenu', (event) => { }); container.appendChild(downMenu); +var aria2RPC = { + server: GM_getValue('server', 'http://localhost:6800/jsonrpc'), + secret: GM_getValue('secret', '') +}; var aria2Menu = document.createElement('div'); -aria2Menu.innerHTML = '\ -'; +aria2Menu.innerHTML = '\ +'; aria2Menu.className = 'menuContainer'; aria2Menu.style.cssText = 'position: absolute; display: none; top: 80px; left: 190px;'; aria2Menu.addEventListener('change', (event) => { var id = event.target.id.replace('assistant_aria2_', ''); - rpc[id] = event.target.value; - GM_setValue(id, rpc[id]); + aria2RPC[id] = event.target.value; + GM_setValue(id, aria2RPC[id]); }); container.appendChild(aria2Menu); function aria2RequestHandler(request, onload, onerror) { GM_xmlhttpRequest({ - url: rpc.server, + url: aria2RPC.server, method: 'POST', data: JSON.stringify({ id: '', jsonrpc: '2.0', method: request.method, - params: ['token:' + rpc.secret].concat(request.options) + params: ['token:' + aria2RPC.secret].concat(request.options) }), onload: onload, onerror: onerror @@ -366,17 +362,10 @@ clickMenu.addEventListener('click', (event) => { }); container.appendChild(clickMenu); -var switchMenu = document.createElement('div'); -switchMenu.innerHTML = '
' + switchIcon(values.lazy) + '' + i18n.lazy.label + '
\ -
' + switchIcon(values.context) + '' + i18n.context.label + '
'; -switchMenu.addEventListener('click', (event) => { - var id = event.target.id.replace('assistant_', ''); - var menu = switchMenu.querySelector('#' + event.target.id); - values[id] = !values[id]; - menu.firstElementChild.innerHTML = switchIcon(values[id]); - GM_setValue(id, values[id]); - if (event.target.id === 'assistant_lazy') { - if (values[id]) { +var switchItem = { + lazy: { + value: GM_getValue('lazy', false), + on: () => { if (!images || !watching.lazyload) { return; } @@ -386,48 +375,57 @@ switchMenu.addEventListener('click', (event) => { clearInterval(lazyload); } }, 100); - } - else { + }, + off: () => { clearInterval(lazyload); } - } - else if (event.target.id === 'assistant_context') { - if (values[id]) { + }, + context: { + value: GM_getValue('context', true), + on: () => { button.style.display = 'none'; - document.addEventListener('contextmenu', contextHandler); - } - else { - document.removeEventListener('contextmenu', contextHandler); + document.addEventListener('contextmenu', switchItem.context.handler); + }, + off: () => { + document.removeEventListener('contextmenu', switchItem.context.handler); button.style.display = 'block'; container.style.top = button.offsetTop + 'px'; container.style.left = button.offsetLeft + button.offsetWidth + 'px'; + }, + handler: (event) => { + if (event.target.id === 'assistant_aria2' || event.shiftKey) { + return; + } + event.preventDefault(); + container.style.top = event.clientY + 'px'; + container.style.left = event.clientX + 'px'; + container.style.display = 'block'; } } +} +var switchMenu = document.createElement('div'); +switchMenu.innerHTML = '
' + i18n.lazy.label + '
\ +
' + i18n.context.label + '
'; +switchMenu.addEventListener('click', (event) => { + var id = event.target.id.replace('assistant_', ''); + var menu = switchMenu.querySelector('#' + event.target.id); + switchItem[id].value = !switchItem[id].value; + GM_setValue(id, switchItem[id].value); + switchHandler(menu, switchItem[id].value, switchItem[id].on, switchItem[id].off) }); switchMenu.className = 'menuContainer'; container.appendChild(switchMenu); -Object.keys(values).forEach(id => { - if (values[id]) { - values[id] = !values[id]; - document.getElementById('assistant_' + id).click(); - } -}); +Object.entries(switchItem).forEach(array => switchHandler(switchMenu.querySelector('#assistant_' + array[0]), array[1].value, array[1].on, array[1].off)); -function contextHandler(event) { - if (event.target.id === 'assistant_aria2' || event.shiftKey) { - return; - } - event.preventDefault(); - container.style.top = event.clientY + 'px'; - container.style.left = event.clientX + 'px'; - container.style.display = 'block'; -} - -function switchIcon(value) { +function switchHandler(menu, value, on, off) { if (value) { - return '✅'; + menu.firstElementChild.innerHTML = '✅'; + if (typeof on === 'function') on(); + } + else { + menu.firstElementChild.innerHTML = ''; + if (typeof off === 'function') off(); } - return ''; } // Extract images data From 56096b5418c90521371e2005f8c9b44f708d0442 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 22:26:55 +0800 Subject: [PATCH 0016/1027] update button css code --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index d994993..76bbdf4 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -209,7 +209,7 @@ button.id = 'assistant_button'; button.innerHTML = '🖱️'; button.className = 'menuOverlay assistantMenu'; button.draggable = true; -button.style.cssText = 'top: ' + position.top + 'px; left: ' + position.left + 'px; text-align: center; padding-top: 10px; width: 42px; height: 42px;'; +button.style.cssText = 'top: ' + position.top + 'px; left: ' + position.left + 'px; text-align: center; vertical-align: middle; width: 42px; height: 42px;'; document.body.appendChild(button); var container = document.createElement('div'); From ff1fe0af3f409fa12436bb49e0ab568f62fa1f47 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 23:44:33 +0800 Subject: [PATCH 0017/1027] more clean up --- RawMangaAssistant.user.js | 61 +++++++++++++++------------------------ 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 76bbdf4..5fa04ca 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -105,7 +105,7 @@ var messages = { lazy: { label: 'Preload All Images' }, - context: { + menu: { label: 'Context Menu Mode' }, extract: { @@ -140,7 +140,7 @@ var messages = { lazy: { label: '预加载所有图像', }, - context: { + menu: { label: '右键菜单模式', }, extract: { @@ -321,31 +321,23 @@ downMenu.addEventListener('contextmenu', (event) => { }); container.appendChild(downMenu); -var aria2RPC = { - server: GM_getValue('server', 'http://localhost:6800/jsonrpc'), - secret: GM_getValue('secret', '') -}; -var aria2Menu = document.createElement('div'); -aria2Menu.innerHTML = '\ -'; +var aria2Menu = document.createElement('form'); +aria2Menu.innerHTML = '\ +'; aria2Menu.className = 'menuContainer'; aria2Menu.style.cssText = 'position: absolute; display: none; top: 80px; left: 190px;'; -aria2Menu.addEventListener('change', (event) => { - var id = event.target.id.replace('assistant_aria2_', ''); - aria2RPC[id] = event.target.value; - GM_setValue(id, aria2RPC[id]); -}); +aria2Menu.addEventListener('change', (event) => GM_setValue(event.target.name, event.target.value)); container.appendChild(aria2Menu); function aria2RequestHandler(request, onload, onerror) { GM_xmlhttpRequest({ - url: aria2RPC.server, + url: aria2Menu.querySelector('#assistant_aria2_server').value, method: 'POST', data: JSON.stringify({ id: '', jsonrpc: '2.0', method: request.method, - params: ['token:' + aria2RPC.secret].concat(request.options) + params: ['token:' + aria2Menu.querySelector('#assistant_aria2_secret').value].concat(request.options) }), onload: onload, onerror: onerror @@ -364,7 +356,6 @@ container.appendChild(clickMenu); var switchItem = { lazy: { - value: GM_getValue('lazy', false), on: () => { if (!images || !watching.lazyload) { return; @@ -380,14 +371,13 @@ var switchItem = { clearInterval(lazyload); } }, - context: { - value: GM_getValue('context', true), + menu: { on: () => { button.style.display = 'none'; - document.addEventListener('contextmenu', switchItem.context.handler); + document.addEventListener('contextmenu', switchItem.menu.handler); }, off: () => { - document.removeEventListener('contextmenu', switchItem.context.handler); + document.removeEventListener('contextmenu', switchItem.menu.handler); button.style.display = 'block'; container.style.top = button.offsetTop + 'px'; container.style.left = button.offsetLeft + button.offsetWidth + 'px'; @@ -404,28 +394,23 @@ var switchItem = { } } var switchMenu = document.createElement('div'); -switchMenu.innerHTML = '
' + i18n.lazy.label + '
\ -
' + i18n.context.label + '
'; +switchMenu.innerHTML = '
' + i18n.lazy.label + '
\ +
' + i18n.menu.label + '
'; switchMenu.addEventListener('click', (event) => { - var id = event.target.id.replace('assistant_', ''); - var menu = switchMenu.querySelector('#' + event.target.id); - switchItem[id].value = !switchItem[id].value; - GM_setValue(id, switchItem[id].value); - switchHandler(menu, switchItem[id].value, switchItem[id].on, switchItem[id].off) + var input = event.target.querySelector('input'); + input.value = input.value === 'on' ? 'off' : 'on'; + GM_setValue(input.name, input.value); + switchHandler(event.target); }); switchMenu.className = 'menuContainer'; container.appendChild(switchMenu); -Object.entries(switchItem).forEach(array => switchHandler(switchMenu.querySelector('#assistant_' + array[0]), array[1].value, array[1].on, array[1].off)); +switchMenu.childNodes.forEach(item => switchHandler(item)); -function switchHandler(menu, value, on, off) { - if (value) { - menu.firstElementChild.innerHTML = '✅'; - if (typeof on === 'function') on(); - } - else { - menu.firstElementChild.innerHTML = ''; - if (typeof off === 'function') off(); - } +function switchHandler(menu) { + var input = menu.querySelector('input'); + var worker = switchItem[input.name][input.value]; + menu.firstElementChild.innerHTML = input.value === 'on' ? '✅' : ''; + if (typeof worker === 'function') { worker(); } } // Extract images data From cb9e0ab8346a01d217199d20800d68b4bf8efcde Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 7 Dec 2020 23:47:11 +0800 Subject: [PATCH 0018/1027] oops, inverted value --- RawMangaAssistant.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 5fa04ca..bca7002 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -394,8 +394,8 @@ var switchItem = { } } var switchMenu = document.createElement('div'); -switchMenu.innerHTML = '
' + i18n.lazy.label + '
\ -
' + i18n.menu.label + '
'; +switchMenu.innerHTML = '
' + i18n.lazy.label + '
\ +
' + i18n.menu.label + '
'; switchMenu.addEventListener('click', (event) => { var input = event.target.querySelector('input'); input.value = input.value === 'on' ? 'off' : 'on'; From 4ab58a3790f4d04962c9cf66276dee2f7a8464dd Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Dec 2020 11:27:22 +0800 Subject: [PATCH 0019/1027] simplified code --- tsdmAutoSignAndWork.user.js | 70 ++++++++++--------------------------- 1 file changed, 19 insertions(+), 51 deletions(-) diff --git a/tsdmAutoSignAndWork.user.js b/tsdmAutoSignAndWork.user.js index 929ec3b..fea1312 100644 --- a/tsdmAutoSignAndWork.user.js +++ b/tsdmAutoSignAndWork.user.js @@ -26,61 +26,29 @@ if (autoed) { } var css = document.createElement('style'); -css.innerHTML = '.my-button {padding: 5px; border: 1px outset #000; text-align: center; background-color: #FFF; width: 50px;}\ +css.innerHTML = '.my-button {padding: 5px; border: 1px outset #000; text-align: center; vertical-align: middle; display: inline-block; background-color: #FFF; width: 60px; height: 20px; cursor: pointer; font-weight: bold;}\ .my-button:hover {filter: opacity(60%);}\ .my-button:active {filter: opacity(30%);}\ -.my-checked {padding: 4px; border: 2px inset #00F;}\ -.my-dropdown {background-color: #FFF;}' +.my-menu {background-color: #fff; position: absolute; top: 15px; left: 100px; z-index: 99999;}' document.head.appendChild(css); -var container = document.createElement('div'); -container.style.cssText = 'position: absolute; top: 3px; left: calc(50% - 50px); font-weight: bold; cursor: pointer;'; -document.body.appendChild(container); - -var menu = document.createElement('div'); -menu.innerHTML = '菜单'; -menu.className = 'my-button'; -menu.addEventListener('click', (event) => { - if (menu.classList.contains('my-checked')) { - box.style.display = 'none'; - } - else { - box.style.display = 'block'; - } - menu.classList.toggle('my-checked'); -}); -container.appendChild(menu); - -var box = document.createElement('div'); -box.className = 'my-dropdown'; -box.style.cssText = 'display: none;'; -container.appendChild(box); - -var sign = document.createElement('div'); -sign.innerHTML = '签到'; -sign.className = 'my-button'; -sign.addEventListener('click', (event) => autoHandler('/plugin.php?id=dsu_paulsign:sign', signHandler)); -box.appendChild(sign); - -var work = document.createElement('div'); -work.innerHTML = '打工'; -work.className = 'my-button'; -work.addEventListener('click', (event) => autoHandler('/plugin.php?id=np_cliworkdz:work', workHandler)); -box.appendChild(work); - -var auto = document.createElement('div'); -auto.className = 'my-button'; -auto.addEventListener('click', (event) => { +var click = [(event) => { + autoHandler('/plugin.php?id=dsu_paulsign:sign', signHandler); +}, (event) => { + autoHandler('/plugin.php?id=np_cliworkdz:work', workHandler); +}, (event) => { autoed = !autoed; - autoIcon.innerHTML = autoed ? '✅' : ''; + menu.querySelector('.my-auto').innerHTML = autoed ? '✅' : ''; GM_setValue('autoed', autoed); -}); -box.appendChild(auto); -var autoIcon = document.createElement('span'); -autoIcon.innerHTML = autoed ? '✅' : ''; -var autoText = document.createTextNode('自动'); -auto.appendChild(autoIcon); -auto.appendChild(autoText); +}]; +var menu = document.createElement('div'); +menu.innerHTML = '签到\ +打工\ +自动'; +menu.className = 'my-menu'; +menu.querySelectorAll('.my-button').forEach((item, index) => item.addEventListener('click', click[index])); +menu.querySelector('.my-auto').innerHTML = autoed ? '✅' : ''; +document.body.appendChild(menu); function autoHandler(url, load) { var id = 'auto-' + url.match(/\w{4}$/)[0]; @@ -114,7 +82,7 @@ function workHandler(node, url, id, warn) { var text = node.querySelector('#messagetext > p:nth-child(1)').innerHTML.split(/
| +``` +### TamperMonkey +```javascript +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-QKUXWW5bZZv7sqNDpGB+nhKv6e2IdGELUp99owlh4dc= +``` +## Syntax +```javascript +const meta4 = toMetalink4(input); +``` +### `input` +An object containing information to generate metalink file `{ name, size, version, locale, hash, url, metaurl }`, or\ +An array `[ { name, size, version, locale, hash, url, metaurl }, { name, size, version, locale, hash, url, metaurl }... ]` +#### url `*required` +The download address of the file\ +String `https://sam.pl/e.zip`\ +Array `[ locale, url ]` to generate `https://sam.pl/e.zip`\ +Array `[ [ locale, url ], [ locale, url ]... ]` for multiple download addresses +####`name `Optional` +The name of the file `` +#### size `Optional` +The size of the file `4279183` +#### version `Optional` +The version of the file `1.0.1` +#### locale `Optional` +The language of the file `en` +#### hash `Optional` +The hash of the file\ +Array `[ type, hash ]` to generate `40a51...1e1d7`\ +Array `[ [ type, hash ], [ type, hash ]... ]` for multiple hashes +#### metaurl `Optional` +Array `[ type, metaurl ]` to generate `https://sam.pl/e.zip.torrent`\ +Array `[ [ type, metaurl ], [ type, metaurl ]... ]` for multiple metaurl addresses +### `meta4` +An object contains the result `{ binary, blob, text, saveAs }` +#### binary +An `array` of text of the result +#### blob +A `blob` object of the result +#### text +A `string` of the result +#### saveAs(filename) `function` +Save the result into a local file. If **filename** is not defined, default filename is `metalink` From 1ec3b0042f9093ed6350635d8a762f752e09aaa2 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 14:52:10 +0800 Subject: [PATCH 0399/1027] Create README.md --- libs/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 libs/README.md diff --git a/libs/README.md b/libs/README.md new file mode 100644 index 0000000..cd30cfb --- /dev/null +++ b/libs/README.md @@ -0,0 +1,2 @@ +## How to use +[metalink.js](libs/HowToUse/metalink4.md) From 717774fc40998e64d5cf441780456ab219b27026 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 14:52:43 +0800 Subject: [PATCH 0400/1027] Update README.md --- libs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/README.md b/libs/README.md index cd30cfb..4164f1b 100644 --- a/libs/README.md +++ b/libs/README.md @@ -1,2 +1,2 @@ ## How to use -[metalink.js](libs/HowToUse/metalink4.md) +[metalink.js](HowToUse/metalink4.md) From 0a98a1ffb64ff025d675734e0bb6fc7ee46cfba2 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 14:56:54 +0800 Subject: [PATCH 0401/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index e3f6168..51c0c33 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -18,7 +18,7 @@ An object containing information to generate metalink file `{ name, size, versio An array `[ { name, size, version, locale, hash, url, metaurl }, { name, size, version, locale, hash, url, metaurl }... ]` #### url `*required` The download address of the file\ -String `https://sam.pl/e.zip`\ +String to generate `https://sam.pl/e.zip`\ Array `[ locale, url ]` to generate `https://sam.pl/e.zip`\ Array `[ [ locale, url ], [ locale, url ]... ]` for multiple download addresses ####`name `Optional` @@ -34,6 +34,7 @@ The hash of the file\ Array `[ type, hash ]` to generate `40a51...1e1d7`\ Array `[ [ type, hash ], [ type, hash ]... ]` for multiple hashes #### metaurl `Optional` +The metaurl address of the file\ Array `[ type, metaurl ]` to generate `https://sam.pl/e.zip.torrent`\ Array `[ [ type, metaurl ], [ type, metaurl ]... ]` for multiple metaurl addresses ### `meta4` From efe5d4601e6aaeb945e6484e8dd6f620116e255d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 15:45:55 +0800 Subject: [PATCH 0402/1027] Update metalink4.js --- libs/metalink4.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/metalink4.js b/libs/metalink4.js index 5b27e43..8e5e4f2 100644 --- a/libs/metalink4.js +++ b/libs/metalink4.js @@ -19,7 +19,7 @@ if (version) { f += '' + version + ''; } if (locale) { f += '' + locale + ''; } if (hash) { if (Array.isArray(hash[0])) { hash.forEach(h => { f += '' + h[1] + ''; }); } else { f += '' + hash[1] + ''; } } - if (Array.isArray(url)) { url.forEach(u => { f += '' + u[1] + ''; }); } else { f += '' + url + ''; } + if (Array.isArray(url)) { url.forEach(u => { f += Array.isArray(u) ? '' + u[1] + '' : '' + u + ''; }); } else { f += '' + url + ''; } if (metaurl) { if (Array.isArray(metaurl[0])) { metaurl.forEach(m => { f += '' + m[1] + ''; }); } else { f += '' + metaurl[1] + ''; } } return f += ''; } From 07c791b3a96c554e1fc6fff8aadc221c2090839b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 15:47:39 +0800 Subject: [PATCH 0403/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index 51c0c33..f3945c0 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -2,12 +2,11 @@ ### HTML ```HTML + integrity="sha256-4W7nOCP6di9pmO+yv1Ta633VGIocNHeGZDwkMIjNiAo=" crossorigin="anonymous"> ``` ### TamperMonkey ```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-QKUXWW5bZZv7sqNDpGB+nhKv6e2IdGELUp99owlh4dc= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-4W7nOCP6di9pmO+yv1Ta633VGIocNHeGZDwkMIjNiAo= ``` ## Syntax ```javascript From 480f165179d099964fe7fdc16461b7966ef6b0c5 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 15:48:17 +0800 Subject: [PATCH 0404/1027] Update metalink4.js --- NarouSyosetuManager.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 4b18ebf..41dc815 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,12 +1,12 @@ // ==UserScript== // @name 小説家になろう 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 4.6 +// @version 4.7 // @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-QKUXWW5bZZv7sqNDpGB+nhKv6e2IdGELUp99owlh4dc= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-4W7nOCP6di9pmO+yv1Ta633VGIocNHeGZDwkMIjNiAo= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue From 85c9fa24703895e5a35e641b90e4151677ccbcae Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 17:11:57 +0800 Subject: [PATCH 0405/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index f3945c0..316a7e1 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -17,9 +17,10 @@ An object containing information to generate metalink file `{ name, size, versio An array `[ { name, size, version, locale, hash, url, metaurl }, { name, size, version, locale, hash, url, metaurl }... ]` #### url `*required` The download address of the file\ -String to generate `https://sam.pl/e.zip`\ +String `url` to generate `https://sam.pl/e.zip`\ +Array `[ url0, url1... ] for multiple download addresses\ Array `[ locale, url ]` to generate `https://sam.pl/e.zip`\ -Array `[ [ locale, url ], [ locale, url ]... ]` for multiple download addresses +Array `[ [ locale0, url0 ], [ locale1, url1 ]... ]` for multiple download addresses with locales ####`name `Optional` The name of the file `` #### size `Optional` @@ -31,11 +32,11 @@ The language of the file `en` #### hash `Optional` The hash of the file\ Array `[ type, hash ]` to generate `40a51...1e1d7`\ -Array `[ [ type, hash ], [ type, hash ]... ]` for multiple hashes +Array `[ [ type0, hash0 ], [ type1, hash1 ]... ]` for multiple hashes #### metaurl `Optional` The metaurl address of the file\ Array `[ type, metaurl ]` to generate `https://sam.pl/e.zip.torrent`\ -Array `[ [ type, metaurl ], [ type, metaurl ]... ]` for multiple metaurl addresses +Array `[ [ type0, metaurl0 ], [ type1, metaurl1 ]... ]` for multiple metaurl addresses ### `meta4` An object contains the result `{ binary, blob, text, saveAs }` #### binary From 86e80c71776d98446f8eeb5d556fc71ec87c066e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 17:37:08 +0800 Subject: [PATCH 0406/1027] fixed restore --- SpeedRunHelper.user.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 773aa73..22012ef 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 2.16 +// @version 2.17 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -29,7 +29,7 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 30%; height: 20px; z-index: 99999;}\ .speedrun-minimum iframe {height: 0px;}\ .speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px; height: ' + (outerHeight - 20) + 'px; z-index: 99999;}\ -.speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ +#speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ .speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; document.body.append(css); @@ -84,7 +84,7 @@ function createRecordWindow(id, content, title) { \ '; document.body.appendChild(container); - content.style.cssText = 'height: calc(100% - 20px); width: 100%;'; + var restore = content.style.cssText = 'height: calc(100% - 20px); width: 100%;'; container.appendChild(content); var index = [...document.querySelectorAll('[id^="speedrun-"]')].findIndex(view => view === container); container.top = container.style.top = 130 + index * 20 + 'px'; @@ -92,18 +92,18 @@ function createRecordWindow(id, content, title) { container.querySelector('#speedrun-minimum').addEventListener('click', event => { container.classList.add('speedrun-minimum'); container.classList.remove('speedrun-maximum'); - style[id] = container.style.cssText ? container.style.cssText : style[id]; + restore = container.style.cssText ? container.style.cssText : restore; container.style.cssText = ''; }); container.querySelector('#speedrun-maximum').addEventListener('click', event => { container.classList.add('speedrun-maximum'); container.classList.remove('speedrun-minimum'); - style[id] = container.style.cssText ? container.style.cssText : style[id]; + restore = container.style.cssText ? container.style.cssText : restore; container.style.cssText = ''; }); container.querySelector('#speedrun-restore').addEventListener('click', event => { container.classList.remove('speedrun-maximum', 'speedrun-minimum'); - container.style.cssText = style[id]; + container.style.cssText = restore; }); container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); From 7f2dac41a3ff2ed3da3b2ef6ecc1cbf0fd30487e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 18:29:58 +0800 Subject: [PATCH 0407/1027] fixed minimum, maximum and drag'n'drop --- SpeedRunHelper.user.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 22012ef..60aee3f 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 2.17 +// @version 2.18 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -19,7 +19,7 @@ var css = document.createElement('style'); css.innerHTML = '#widget {display: none !important;}\ #centerwidget {width: 100% !important;}\ .speedrun-window {position: fixed; width: 1280px; height: 740px; z-index: 999;}\ -.speedrun-window iframe {height: calc(100% - 20px); width: 100%;}\ +.speedrun-window iframe {width: 1280px !important; height: 720px !important;}\ .speedrun-top {position: relative; background-color: #52698A; width: 100%; user-select: none; height: 20px;}\ .speedrun-title > * {display: inline-block; width: 25%;}\ .speedrun-menu {position: absolute; right: 0px; top: 0px;}\ @@ -27,8 +27,9 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-item:hover {filter: opacity(60%);}\ .speedrun-item:active {filter: opacity(30%);}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 30%; height: 20px; z-index: 99999;}\ -.speedrun-minimum iframe {height: 0px;}\ +.speedrun-minimum iframe {display: none !important;}\ .speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px; height: ' + (outerHeight - 20) + 'px; z-index: 99999;}\ +.speedrun-maximum iframe {width: 100% !important; height: calc(100% - 20px) !important;}\ #speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ .speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; document.body.append(css); @@ -44,16 +45,15 @@ document.getElementById('leaderboarddiv').addEventListener('contextmenu', event var record = row.classList.contains('center-sm') ? {rank: 1, time: 2} : row.classList.contains('height-minimal') ? {rank: 1, player: 2, time: 3} : {rank: 0, player: 1, time: 2}; var player = record.player ? cells[record.player].innerText : document.querySelector('.profile-username').innerText; var title = '
Rank : ' + cells[record.rank].innerHTML + ' Player : ' + player + ' Time : ' + cells[record.time].innerHTML + ''; - viewSpeedrunRecord({id, src, title}); + viewSpeedrunRecord(id, title, src); } } }); -function viewSpeedrunRecord({id, src, title}) { +function viewSpeedrunRecord(id, title, src) { var view = document.querySelector('#speedrun-' + id); if (view) { - view.style.top = view.top; - view.style.left = view.left; + view.style.cssText = 'top: ' + style[id].top + 'px; left: ' + style[id].width + 'px;' } else if (logger[id]) { createRecordWindow(id, logger[id], title); @@ -63,17 +63,18 @@ function viewSpeedrunRecord({id, src, title}) { var xml = document.createElement('div'); xml.innerHTML = htmlText; logger[id] = xml.querySelector('#centerwidget iframe') ?? xml.querySelector('#centerwidget p > a'); - createRecordWindow(id, logger[id], title); + createRecordWindow(id, title, logger[id]); xml.remove(); }); } } -function createRecordWindow(id, content, title) { +function createRecordWindow(id, title, content) { if (content.tagName === 'A') { return open(content.href, '_blank'); } + var index = document.querySelectorAll('[id^="speedrun-"]').length; var container = document.createElement('div'); container.id = 'speedrun-' + id; container.draggable = 'true'; @@ -84,26 +85,21 @@ function createRecordWindow(id, content, title) { \
'; document.body.appendChild(container); - var restore = content.style.cssText = 'height: calc(100% - 20px); width: 100%;'; container.appendChild(content); - var index = [...document.querySelectorAll('[id^="speedrun-"]')].findIndex(view => view === container); - container.top = container.style.top = 130 + index * 20 + 'px'; - container.left = container.style.left = (screen.availWidth - 1280) / 2 + index * 20 + 'px'; + style[id] = container.style.cssText = 'top: ' + (130 + index * 20) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + index * 20) + 'px;'; container.querySelector('#speedrun-minimum').addEventListener('click', event => { container.classList.add('speedrun-minimum'); container.classList.remove('speedrun-maximum'); - restore = container.style.cssText ? container.style.cssText : restore; container.style.cssText = ''; }); container.querySelector('#speedrun-maximum').addEventListener('click', event => { container.classList.add('speedrun-maximum'); container.classList.remove('speedrun-minimum'); - restore = container.style.cssText ? container.style.cssText : restore; container.style.cssText = ''; }); container.querySelector('#speedrun-restore').addEventListener('click', event => { container.classList.remove('speedrun-maximum', 'speedrun-minimum'); - container.style.cssText = restore; + container.style.cssText = style[id]; }); container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); @@ -115,6 +111,8 @@ document.addEventListener('dragstart', event => { offset.left = event.clientX }); document.addEventListener('dragend', event => { - event.target.style.top = event.target.offsetTop + event.clientY - offset.top + 'px'; - event.target.style.left = event.target.offsetLeft + event.clientX - offset.left + 'px'; + if (!event.target.classList.contains('speedrun-minimum')) { + var id = event.target.id.slice(event.target.id.indexOf('-') + 1); + style[id] = event.target.style.cssText = 'top: ' + (event.target.offsetTop + event.clientY - offset.top) + 'px; left: ' + (event.target.offsetLeft + event.clientX - offset.left) + 'px;'; + } }); From d87212b707519779fc3a89cd63f7855da7b9466b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 18:47:33 +0800 Subject: [PATCH 0408/1027] clean up --- SpeedRunHelper.user.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 60aee3f..37ce91e 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -12,8 +12,8 @@ 'use strict'; var logger = {}; -var offset = {}; var style = {}; +var offset; var css = document.createElement('style'); css.innerHTML = '#widget {display: none !important;}\ @@ -107,8 +107,7 @@ function createRecordWindow(id, title, content) { } document.addEventListener('dragstart', event => { - offset.top = event.clientY; - offset.left = event.clientX + offset = { top: event.clientY, left: event.clientX }; }); document.addEventListener('dragend', event => { if (!event.target.classList.contains('speedrun-minimum')) { From c469ff25aa04ae232440eaa4a778c2b29fd7339b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 18:52:54 +0800 Subject: [PATCH 0409/1027] fixed drag'n'drop when maximum, fixed position --- SpeedRunHelper.user.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 37ce91e..9204712 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 2.18 +// @version 2.19 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -53,7 +53,8 @@ document.getElementById('leaderboarddiv').addEventListener('contextmenu', event function viewSpeedrunRecord(id, title, src) { var view = document.querySelector('#speedrun-' + id); if (view) { - view.style.cssText = 'top: ' + style[id].top + 'px; left: ' + style[id].width + 'px;' + var index = document.querySelectorAll('[id^="speedrun-"]').length; + style[id] = view.style.cssText = 'top: ' + (130 + index * 20) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + index * 20) + 'px;'; } else if (logger[id]) { createRecordWindow(id, logger[id], title); @@ -74,7 +75,6 @@ function createRecordWindow(id, title, content) { return open(content.href, '_blank'); } - var index = document.querySelectorAll('[id^="speedrun-"]').length; var container = document.createElement('div'); container.id = 'speedrun-' + id; container.draggable = 'true'; @@ -86,6 +86,7 @@ function createRecordWindow(id, title, content) { '; document.body.appendChild(container); container.appendChild(content); + var index = document.querySelectorAll('[id^="speedrun-"]').length; style[id] = container.style.cssText = 'top: ' + (130 + index * 20) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + index * 20) + 'px;'; container.querySelector('#speedrun-minimum').addEventListener('click', event => { container.classList.add('speedrun-minimum'); @@ -110,7 +111,7 @@ document.addEventListener('dragstart', event => { offset = { top: event.clientY, left: event.clientX }; }); document.addEventListener('dragend', event => { - if (!event.target.classList.contains('speedrun-minimum')) { + if (event.target.className === 'speedrun-window') { var id = event.target.id.slice(event.target.id.indexOf('-') + 1); style[id] = event.target.style.cssText = 'top: ' + (event.target.offsetTop + event.clientY - offset.top) + 'px; left: ' + (event.target.offsetLeft + event.clientX - offset.left) + 'px;'; } From 9a7901205c5aecd6494555e2ef8bb280404b6e1b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 19:01:40 +0800 Subject: [PATCH 0410/1027] fixed new window --- SpeedRunHelper.user.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 9204712..4328a5b 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -53,8 +53,7 @@ document.getElementById('leaderboarddiv').addEventListener('contextmenu', event function viewSpeedrunRecord(id, title, src) { var view = document.querySelector('#speedrun-' + id); if (view) { - var index = document.querySelectorAll('[id^="speedrun-"]').length; - style[id] = view.style.cssText = 'top: ' + (130 + index * 20) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + index * 20) + 'px;'; + style[id] = view.style.cssText = 'top: ' + (130 + view.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + view.idx * 30) + 'px;'; } else if (logger[id]) { createRecordWindow(id, logger[id], title); @@ -63,7 +62,7 @@ function viewSpeedrunRecord(id, title, src) { fetch(src).then(response => response.text()).then(htmlText => { var xml = document.createElement('div'); xml.innerHTML = htmlText; - logger[id] = xml.querySelector('#centerwidget iframe') ?? xml.querySelector('#centerwidget p > a'); + logger[id] = xml.querySelector('#centerwidget iframe') ?? xml.querySelector('#centerwidget a[rel="noopener"]'); createRecordWindow(id, title, logger[id]); xml.remove(); }); @@ -77,6 +76,7 @@ function createRecordWindow(id, title, content) { var container = document.createElement('div'); container.id = 'speedrun-' + id; + container.idx = document.querySelectorAll('.speedrun-window').length; container.draggable = 'true'; container.className = 'speedrun-window'; container.innerHTML = '
' + title + '
\ @@ -86,8 +86,7 @@ function createRecordWindow(id, title, content) { '; document.body.appendChild(container); container.appendChild(content); - var index = document.querySelectorAll('[id^="speedrun-"]').length; - style[id] = container.style.cssText = 'top: ' + (130 + index * 20) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + index * 20) + 'px;'; + style[id] = container.style.cssText = 'top: ' + (130 + container.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + container.idx * 30) + 'px;'; container.querySelector('#speedrun-minimum').addEventListener('click', event => { container.classList.add('speedrun-minimum'); container.classList.remove('speedrun-maximum'); From 2482ef228f6516ac6d7ad96d8051d10dee95d14b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 19:05:28 +0800 Subject: [PATCH 0411/1027] oops --- SpeedRunHelper.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 4328a5b..d560d58 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -56,7 +56,7 @@ function viewSpeedrunRecord(id, title, src) { style[id] = view.style.cssText = 'top: ' + (130 + view.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + view.idx * 30) + 'px;'; } else if (logger[id]) { - createRecordWindow(id, logger[id], title); + createRecordWindow(id, title, logger[id]); } else { fetch(src).then(response => response.text()).then(htmlText => { From d4f2bd5ad5a51ba9f7710bdb8b481a5cf8de5ed0 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 20:46:45 +0800 Subject: [PATCH 0412/1027] minor ui --- SpeedRunHelper.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index d560d58..e3b1668 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -23,7 +23,7 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-top {position: relative; background-color: #52698A; width: 100%; user-select: none; height: 20px;}\ .speedrun-title > * {display: inline-block; width: 25%;}\ .speedrun-menu {position: absolute; right: 0px; top: 0px;}\ -.speedrun-item {background-color: #fff; cursor: pointer; display: inline-block; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 5px;}\ +.speedrun-item {background-color: #fff; cursor: pointer; display: inline-block; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 2px;}\ .speedrun-item:hover {filter: opacity(60%);}\ .speedrun-item:active {filter: opacity(30%);}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 30%; height: 20px; z-index: 99999;}\ From 3f281873cb97c16ef91c4fe6d2091b416de43a35 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 31 Dec 2021 23:36:19 +0800 Subject: [PATCH 0413/1027] clean up --- RawMangaAssistant.user.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 55e5c5c..5ed3aa8 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -62,7 +62,7 @@ var images; var watching; var options = GM_getValue('options', {server: 'http://localhost:6800/jsonrpc', secret: '', menu: true}); var visual = {height: document.documentElement.clientHeight, width: document.documentElement.clientWidth}; -var offset = {}; +var offset; var position = GM_getValue('position', {top: visual.height * 0.3, left: visual.width * 0.15}); var warning; var headers = {'Cookie': document.cookie, 'Referer': location.href, 'User-Agent': navigator.userAgent}; @@ -245,18 +245,15 @@ document.body.appendChild(container); // Draggable button and menu button.addEventListener('dragstart', event => { - offset.top = event.clientY; - offset.left = event.clientX + offset = {top: event.clientY, left: event.clientX}; }); button.addEventListener('dragend', event => { - var maxHeight = visual.height - button.offsetHeight; - var maxWidth = visual.width - button.offsetWidth; - position.top += event.clientY - offset.top; - position.left += event.clientX - offset.left; - position.top = position.top < 0 ? 0 : position.top; - position.top = position.top > maxHeight ? maxHeight : position.top; - position.left = position.left < 0 ? 0 : position.left; - position.left = position.left > maxWidth ? maxWidth : position.left; + var height = visual.height - button.offsetHeight; + var width = visual.width - button.offsetWidth; + var top = position.top + event.clientY - offset.top; + var left = position.left + event.clientX - offset.left; + position.top = top < 0 ? 0 : top > height ? height : top; + position.left = left < 0 ? 0 : left > width ? width : left; button.style.top = position.top + 'px'; button.style.left = position.left + 'px'; container.style.top = button.offsetTop + 'px'; @@ -319,15 +316,13 @@ downMenu.querySelector('#aria2option').addEventListener('click', event => { }); function checkAria2Availability() { - aria2RequestHandler({method: 'aria2.getGlobalOption'}) - .then(result => { + aria2RequestHandler({method: 'aria2.getGlobalOption'}).then(result => { folder = result['dir'] + extractMangaTitle(); downMenu.querySelector('#aria2download').style.display = 'block'; }).catch(error => notification('aria2', 'error')); } function aria2RequestHandler({method, params = []}) { - return fetch(options.server, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: '2.0', method, params: ['token:' + options.secret, ...params]})}) - .then(response => { + return fetch(options.server, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: '2.0', method, params: ['token:' + options.secret, ...params]})}).then(response => { if (response.ok) { return response.json(); } @@ -408,12 +403,12 @@ if (watching) { removeAdsElement(); } if (watching.chapter.test(location.pathname)) { - checkAria2Availability(); if (watching.shortcut) { appendShortcuts(); } images = document.querySelectorAll(watching.selector); if (images.length > 0) { + checkAria2Availability(); extractImage(); } else { From 91513da8898095ab7d20188eeca0b6a32811615b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 13:13:55 +0800 Subject: [PATCH 0414/1027] clean up --- RawMangaAssistant.user.js | 66 +++++++++++++++------------------------ 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 5ed3aa8..0942c01 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.3 +// @version 6.4 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -102,8 +102,7 @@ var message = { start: 'Extracting manga source', done: 'A total of %n% image urls has been extracted', fail: 'Download function not available due to extraction failure', - error: 'Can\'t be extracted image extension', - fatal: 'No manga source for extraction. Please send feedback' + error: 'Can\'t be extracted image extension' } }, 'zh-CN': { @@ -139,8 +138,7 @@ var message = { start: '正在解析图像来源', done: '已成功解析全部 %n% 图像来源', fail: '无法解析图像来源,下载功能无法使用', - error: '无法解析图像后缀', - fatal: '无法获取图像来源,请反馈问题' + error: '无法解析图像后缀' } } }; @@ -149,51 +147,44 @@ var i18n = message[navigator.language] ?? message['en-US']; // Supported sites var manga = { 'ja.mangatoro.com': { - chapter: /\/chapter-\d+/, - title: {reg: /^(.+)\schap\s([^\s]+)/, sel: 'div.page-chapter > img', attr: 'alt', tl: 1, ch: 2}, - selector: 'div.page-chapter > img', - lazyload: 'data-original' + image: 'div.page-chapter > img', + lazyload: 'data-original', + title: {reg: /^(.+)\schap\s([^\s]+)/, sel: 'div.page-chapter > img', attr: 'alt', tl: 1, ch: 2} }, 'mikaraw.com': { - chapter: /\/chapter-\d+/, + image: 'div.chapter-c > img', + lazyload: 'data-src', title: [{reg: /^([^(])+/, sel: '#header-bot li:nth-child(2) a', attr: 'title', nl: 0}, {reg: /([^\s]+)$/, sel: '#header-bot li:nth-child(3) a', attr: 'title', nl: 0}], shortcut: ['#prev_chap', '#next_chap'], - ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'], - selector: 'div.chapter-c > img', - lazyload: 'data-src' + ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'] }, 'klmanga.com': { - chapter: /chapter-\d+/, + image: 'img.chapter-img', + lazyload: 'data-aload', title: {reg: /^(.+)\sChapter\s([^\s]+)/, sel: 'li.current > a', attr: 'title', tl: 1, ch: 2}, shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'], - ads: ['#id-custom_banner', 'div.float-ck'], - selector: 'img.chapter-img', - lazyload: 'data-aload' + ads: ['#id-custom_banner', 'div.float-ck'] }, 'rawdevart.com': { - chapter: /\/chapter-\d+/, - title: {reg: /^Chapter\s([^\s]+)\s\|\s(.+)\sPage/, sel: '#img-container > div > img', attr: 'alt', tl: 2, ch: 1}, - selector: '#img-container > div > img', - lazyload: 'data-src' + image: '#img-container > div > img', + lazyload: 'data-src', + title: {reg: /^Chapter\s([^\s]+)\s\|\s(.+)\sPage/, sel: '#img-container > div > img', attr: 'alt', tl: 2, ch: 1} }, 'manga1000.com': { - chapter: /-raw\/$/, + image: 'img.aligncenter', title: {reg: /^(.+)\s-\sRaw\s【第(.+)話】/, sel: 'img.aligncenter', attr: 'alt', tl: 1, ch: 2}, - shortcut: 'div.linkchap > a', - selector: 'img.aligncenter' + shortcut: 'div.linkchap > a' }, 'weloma.art': { - chapter: /\d+\/\d+/, + image: 'img.chapter-img', + lazyload: 'data-srcset', title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, - shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'], - selector: 'img.chapter-img', - lazyload: 'data-srcset' + shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'] }, 'mangameta.com': { - chapter: /\/chapter-\d+/, + image: 'div.chapter-c > img', title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, - shortcut: 'div.linkchap > a', - selector: 'div.chapter-c > img' + shortcut: 'div.linkchap > a' } }; manga['manga1001.com'] = manga['manga1000.com']; @@ -402,18 +393,13 @@ if (watching) { if (watching.ads) { removeAdsElement(); } - if (watching.chapter.test(location.pathname)) { + images = document.querySelectorAll(watching.image); + if (images.length > 0) { + checkAria2Availability(); + extractImage(); if (watching.shortcut) { appendShortcuts(); } - images = document.querySelectorAll(watching.selector); - if (images.length > 0) { - checkAria2Availability(); - extractImage(); - } - else { - notification('extract', 'fatal'); - } } } From e65e92fb68955ea00d61041fe4170fc58b728bd1 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 18:54:38 +0800 Subject: [PATCH 0415/1027] add aria2request.js --- libs/aria2request.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 libs/aria2request.js diff --git a/libs/aria2request.js b/libs/aria2request.js new file mode 100644 index 0000000..4b66fc9 --- /dev/null +++ b/libs/aria2request.js @@ -0,0 +1,11 @@ +(function () { + this.aria2 = { + jsonrpc: null, + secret: null, + request: (m, p) => { + fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret, ...p]})}).then(r => { + if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } + }); + } + }; +})(); From 3cd761ab33a47144c6a6868aed912e076625edd0 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 19:36:52 +0800 Subject: [PATCH 0416/1027] oops, fixed function --- libs/aria2request.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 4b66fc9..b91e9dc 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -2,8 +2,8 @@ this.aria2 = { jsonrpc: null, secret: null, - request: (m, p) => { - fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret, ...p]})}).then(r => { + request: (m, p = []) => { + return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret, ...p]})}).then(r => { if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } }); } From 6f7b3f9ccf376b2f9d10fba32034023d26c99a32 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 19:51:45 +0800 Subject: [PATCH 0417/1027] oops --- libs/aria2request.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index b91e9dc..5519e81 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -3,9 +3,8 @@ jsonrpc: null, secret: null, request: (m, p = []) => { - return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret, ...p]})}).then(r => { - if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } - }); + return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret, ...p]})}) + .then(r => { if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } }).then(j => { return 'result' in j ? j.result : j.error; }); } }; })(); From 4df8d5ea1653e53395a7efd3f4e2c7ad0a01d268 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 19:55:38 +0800 Subject: [PATCH 0418/1027] use libs/aria2request.js --- RawMangaAssistant.user.js | 73 +++++++++++++++------------------------ 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 0942c01..0f99054 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.4 +// @version 6.5 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -16,6 +16,7 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-3fyzgot+aKs1bNIwJJRqfzvFfYLYtEc6rGwuv0b3Ed0= // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest @@ -60,10 +61,10 @@ var folder; var observer; var images; var watching; -var options = GM_getValue('options', {server: 'http://localhost:6800/jsonrpc', secret: '', menu: true}); +aria2 = {...aria2, ...GM_getValue('aria2', {jsonrpc: 'http://localhost:6800/jsonrpc', secret: ''})}; +var options = GM_getValue('options', {menu: 'on', top: 300, left: 150}); var visual = {height: document.documentElement.clientHeight, width: document.documentElement.clientWidth}; var offset; -var position = GM_getValue('position', {top: visual.height * 0.3, left: visual.width * 0.15}); var warning; var headers = {'Cookie': document.cookie, 'Referer': location.href, 'User-Agent': navigator.userAgent}; var aria2Headers = ['Cookie: ' + document.cookie, 'Referer: ' + location.href, 'User-Agent:' + navigator.userAgent]; @@ -213,26 +214,25 @@ function extractMangaTitle(title = '') { var css = document.createElement('style'); css.innerHTML = '.menuOverlay {background-color: #fff; position: fixed; z-index: 999999999;}\ .menuContainer {background-color: #fff; min-width: fit-content; max-width: 330px; border: 1px ridge darkblue; font-size: 14px;}\ -.assistantIcon {width: 30px; display: inline-block; text-align: center}\ .assistantMenu {color: black; width: 190px; padding: 10px; height: 40px; display: block; user-select: none;}\ -.assistantMenu:hover {background-color: darkviolet !important; color: white; cursor: default;}'; +.assistantMenu:hover {background-color: darkviolet !important; color: white; cursor: default;}\ +.assistantIcon {width: 30px; display: inline-block; text-align: center}'; +document.body.appendChild(css); var button = document.createElement('span'); button.id = 'assistant_button'; button.innerHTML = '🖱️'; button.className = 'menuOverlay assistantMenu'; +button.style.cssText = 'top: ' + options.top + 'px; left: ' + options.left + 'px; text-align: center; vertical-align: middle; width: 42px; height: 42px; border: 1px solid darkviolet;'; button.draggable = true; -button.style.cssText = 'top: ' + position.top + 'px; left: ' + position.left + 'px; text-align: center; vertical-align: middle; width: 42px; height: 42px; border: 1px solid darkviolet;'; button.addEventListener('click', event => { container.style.display = 'block'; }); -document.body.append(button, css); - var container = document.createElement('div'); container.id = 'assistant_container'; container.className = 'menuOverlay'; -container.style.cssText = 'top: ' + position.top + 'px; left: ' + (position.left + button.offsetWidth) + 'px; display: none'; -document.body.appendChild(container); +container.style.cssText = 'top: ' + options.top + 'px; left: ' + (options.left + button.offsetWidth) + 'px; display: none'; +document.body.append(button, container); // Draggable button and menu button.addEventListener('dragstart', event => { @@ -241,15 +241,15 @@ button.addEventListener('dragstart', event => { button.addEventListener('dragend', event => { var height = visual.height - button.offsetHeight; var width = visual.width - button.offsetWidth; - var top = position.top + event.clientY - offset.top; - var left = position.left + event.clientX - offset.left; - position.top = top < 0 ? 0 : top > height ? height : top; - position.left = left < 0 ? 0 : left > width ? width : left; - button.style.top = position.top + 'px'; - button.style.left = position.left + 'px'; + var top = options.top + event.clientY - offset.top; + var left = options.left + event.clientX - offset.left; + options.top = top < 0 ? 0 : top > height ? height : top; + options.left = left < 0 ? 0 : left > width ? width : left; + button.style.top = options.top + 'px'; + button.style.left = options.left + 'px'; container.style.top = button.offsetTop + 'px'; container.style.left = button.offsetLeft + button.offsetWidth + 'px'; - GM_setValue('position', position); + GM_setValue('options', options); }); document.addEventListener('click', event => { container.style.display = button.contains(event.target) ? 'block' : 'none'; @@ -259,7 +259,7 @@ document.addEventListener('click', event => { var downMenu = document.createElement('div'); downMenu.innerHTML = '
💾' + i18n.save.label + '
\
📄' + i18n.copy.label + '
\ -\ +
🖅' + i18n.aria2.label + '
\
⚙️' + i18n.aria2.option + '
'; downMenu.className = 'menuContainer'; downMenu.style.display = 'none'; @@ -290,43 +290,26 @@ downMenu.querySelector('#clipboard').addEventListener('click', event => { }); // Aria2 Menuitems downMenu.querySelector('#aria2download').addEventListener('click', event => { - urls.forEach((url, index) => aria2RequestHandler({ - method: 'aria2.addUri', - params: [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}] - }).then(result => { + urls.forEach((url, index) => aria2.request('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]).then(result => { if (index === urls.length - 1) { notification('aria2', 'done'); } })); }); downMenu.querySelector('#aria2option').addEventListener('click', event => { - options.server = prompt('Aria2 JSONRPC URI', options.server) ?? options.server; - options.secret = prompt('Aria2 Secret Token', options.secret) ?? options.secret; - GM_setValue('options', options); + aria2.jsonrpc = prompt('Aria2 JSONRPC URI', aria2.jsonrpc) ?? aria2.jsonrpc; + aria2.secret = prompt('Aria2 Secret Token', aria2.secret) ?? aria2.secret; + GM_setValue('aria2', aria2); checkAria2Availability(); }); function checkAria2Availability() { - aria2RequestHandler({method: 'aria2.getGlobalOption'}).then(result => { - folder = result['dir'] + extractMangaTitle(); + aria2.request('aria2.getGlobalOption').then(result => { + folder = result.dir + extractMangaTitle(); downMenu.querySelector('#aria2download').style.display = 'block'; - }).catch(error => notification('aria2', 'error')); -} -function aria2RequestHandler({method, params = []}) { - return fetch(options.server, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: '2.0', method, params: ['token:' + options.secret, ...params]})}).then(response => { - if (response.ok) { - return response.json(); - } - else { - throw response.statusText; - } - }).then(json => { - if (json.result) { - return json.result; - } - if (json.error) { - throw json.error.message; - } + }).catch(error => { + notification('aria2', 'error'); + downMenu.querySelector('#aria2download').style.display = 'none'; }); } @@ -362,7 +345,7 @@ switchMenu.addEventListener('click', event => { var name = event.target.getAttribute('name'); options[name] = options[name] === 'on' ? 'off' : 'on'; switchHandler(event.target); - GM_setValue(name, options[name]); + GM_setValue('options', options); }); container.appendChild(switchMenu); From 87dfb12d892b29bc664088595b4ac71b7221c8be Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 21:04:46 +0800 Subject: [PATCH 0419/1027] support multi request callback --- libs/aria2request.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 5519e81..8ace3f9 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -2,9 +2,17 @@ this.aria2 = { jsonrpc: null, secret: null, - request: (m, p = []) => { - return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret, ...p]})}) - .then(r => { if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } }).then(j => { return 'result' in j ? j.result : j.error; }); - } + send: (m, p) => s({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret].concat(p ?? [])}), + multi: (p) => s({id: '', jsonrpc: 2, method: 'system.multicall', params: [p.map(m)]}) }; + + function s(j) { + return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) + .then(r => { if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } }) + .then(j => { return 'result' in j ? j.result : j.error; }); + } + + function m({method, params}) { + return {methodName: method, params: ['token:' + aria2.secret].concat(params ?? [])}; + } })(); From 08afa30018c403c7e542414f70f5f5c8d3360869 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 1 Jan 2022 21:06:02 +0800 Subject: [PATCH 0420/1027] update aria2request.js --- RawMangaAssistant.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 0f99054..50065dc 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,7 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-3fyzgot+aKs1bNIwJJRqfzvFfYLYtEc6rGwuv0b3Ed0= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-6gpigHvgEesYm635dyvOCRUHcXRFAaRj9X0BfEmJ+rs= // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest @@ -290,7 +290,7 @@ downMenu.querySelector('#clipboard').addEventListener('click', event => { }); // Aria2 Menuitems downMenu.querySelector('#aria2download').addEventListener('click', event => { - urls.forEach((url, index) => aria2.request('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]).then(result => { + urls.forEach((url, index) => aria2.send('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]).then(result => { if (index === urls.length - 1) { notification('aria2', 'done'); } @@ -304,7 +304,7 @@ downMenu.querySelector('#aria2option').addEventListener('click', event => { }); function checkAria2Availability() { - aria2.request('aria2.getGlobalOption').then(result => { + aria2.send('aria2.getGlobalOption').then(result => { folder = result.dir + extractMangaTitle(); downMenu.querySelector('#aria2download').style.display = 'block'; }).catch(error => { From 07528de8cb0a48cb2c2de044c96bc90b6bd000ad Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 09:21:18 +0800 Subject: [PATCH 0421/1027] oops --- libs/aria2request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 8ace3f9..b12b00d 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -9,7 +9,7 @@ function s(j) { return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) .then(r => { if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } }) - .then(j => { return 'result' in j ? j.result : j.error; }); + .then(j => { if ('result' in j) { return j.result; } else { throw j.error; } }); } function m({method, params}) { From 008951253ff48b0e5d0fdecc4c514b3e1c1960d9 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 09:35:37 +0800 Subject: [PATCH 0422/1027] add aria2request.js --- libs/HowToUse/aria2request.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 libs/HowToUse/aria2request.md diff --git a/libs/HowToUse/aria2request.md b/libs/HowToUse/aria2request.md new file mode 100644 index 0000000..60f5d09 --- /dev/null +++ b/libs/HowToUse/aria2request.md @@ -0,0 +1,24 @@ +## How to implement +### HTML +```HTML + +``` +### TamperMonkey +```javascript +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo= +``` +## Syntax +```javascript +const aria2.jsonrpc = 'http://localhost:6800/jsonrpc'; +const aria2.secret = 'Your secret token'; +const result = aria2.send(method, params); +const arrayResult = aria2.multi([ {method0, params0}, {method1, params1} ]); +``` +### `method` `*required`, `params` `Optional` +Read [RPC method calls](https://aria2.github.io/manual/en/html/aria2c.html#methods) +### `result` +Promise object, returns an `object` if fufilled +### `arrayResult` +Promise object, returns an `array` if fufilled\ +`[ [result0], [result1], ... ]` From 9d979f01243192046bd453b3ec6b60aeae8d067b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 09:37:20 +0800 Subject: [PATCH 0423/1027] add aria2request.js and aria2request.md --- libs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/README.md b/libs/README.md index 4164f1b..d979759 100644 --- a/libs/README.md +++ b/libs/README.md @@ -1,2 +1,3 @@ ## How to use +[aria2request.js](HowToUse/aria2request.md) [metalink.js](HowToUse/metalink4.md) From f7b6644e03314ab9d3951d895121940dc510b96d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 09:37:51 +0800 Subject: [PATCH 0424/1027] Update README.md --- libs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/README.md b/libs/README.md index d979759..fe2d3c7 100644 --- a/libs/README.md +++ b/libs/README.md @@ -1,3 +1,3 @@ ## How to use -[aria2request.js](HowToUse/aria2request.md) -[metalink.js](HowToUse/metalink4.md) +#### [aria2request.js](HowToUse/aria2request.md) +#### [metalink.js](HowToUse/metalink4.md) From d0bd6618468d4343be6ff8419438aab85cccc9e4 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 09:56:01 +0800 Subject: [PATCH 0425/1027] add dragndrop.js --- libs/dragndrop.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 libs/dragndrop.js diff --git a/libs/dragndrop.js b/libs/dragndrop.js new file mode 100644 index 0000000..fa68829 --- /dev/null +++ b/libs/dragndrop.js @@ -0,0 +1,7 @@ +(function() { + this.dragndrop = n => { + n.draggable=true,x,y,h=visual.height-n.offsetHeight,w=visual.width-n.offsetWidth; + n.addEventListener('dragstart', e => { x=e.clientX,y=e.clientY; }); + n.addEventListener('dragend', e => {n.style.cssText='top:'+(n.offsetTop+e.clientY-y)+'px;left:'+(n.offsetLeft+e.clientX-x)+'px;';}); + }; +})(); From 4a7d7626b1ecf7686ce5f7ca344789642d8b8435 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 10:11:33 +0800 Subject: [PATCH 0426/1027] Update dragndrop.js --- libs/dragndrop.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index fa68829..75450c2 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,7 +1,20 @@ (function() { this.dragndrop = n => { - n.draggable=true,x,y,h=visual.height-n.offsetHeight,w=visual.width-n.offsetWidth; - n.addEventListener('dragstart', e => { x=e.clientX,y=e.clientY; }); - n.addEventListener('dragend', e => {n.style.cssText='top:'+(n.offsetTop+e.clientY-y)+'px;left:'+(n.offsetLeft+e.clientX-x)+'px;';}); + var x, y; + var h = visual.height - n.offsetHeight; + var w = visual.width - n.offsetWidth; + n.draggable=true; + n.addEventListener('dragstart', e => { + x = e.clientX; + y = e.clientY; + }); + n.addEventListener('dragend', e => { + x = n.offsetLeft + e.clientX - x; + y = n.offsetTop + e.clientY - y; + x= x < 0 ? 0 : x > w ? w : x; + y = y < 0 ? 0 : y > h ? h :y; + n.style.left = x + 'px'; + n.style.top = y + 'px'; + }); }; })(); From 1e9e07ca10263198d6659fd5a5b441a4f1669d5d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 10:32:22 +0800 Subject: [PATCH 0427/1027] Update dragndrop.js --- libs/dragndrop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index 75450c2..243c833 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,8 +1,8 @@ (function() { this.dragndrop = n => { var x, y; - var h = visual.height - n.offsetHeight; - var w = visual.width - n.offsetWidth; + var h = innerHeight - n.offsetHeight; + var w = innerWidth - n.offsetWidth; n.draggable=true; n.addEventListener('dragstart', e => { x = e.clientX; From 3f1bcd9a6999bc18086d8da3486fe1759a3685ee Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 10:33:06 +0800 Subject: [PATCH 0428/1027] Update dragndrop.js --- libs/dragndrop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index 243c833..c921837 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,8 +1,8 @@ (function() { this.dragndrop = n => { var x, y; - var h = innerHeight - n.offsetHeight; - var w = innerWidth - n.offsetWidth; + var h = document.documentElement.clientHeight - n.offsetHeight; + var w = document.documentElement.clientWidth - n.offsetWidth; n.draggable=true; n.addEventListener('dragstart', e => { x = e.clientX; From 81c5c61f80a97242067783adbd167f952e1822ad Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 10:56:53 +0800 Subject: [PATCH 0429/1027] oops --- libs/dragndrop.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index c921837..35d658e 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,18 +1,20 @@ (function() { - this.dragndrop = n => { - var x, y; - var h = document.documentElement.clientHeight - n.offsetHeight; - var w = document.documentElement.clientWidth - n.offsetWidth; + this.dragndrop = (n, {width, height}) => { + var x, y, w, h; + var d = width ?? 0; + var t = height ?? 0; n.draggable=true; n.addEventListener('dragstart', e => { x = e.clientX; y = e.clientY; }); n.addEventListener('dragend', e => { + w = document.documentElement.clientWidth > n.offsetWidth ? document.documentElement.clientWidth - n.offsetWidth : 0; + h = document.documentElement.clientHeight > n.offsetHeight ? document.documentElement.clientHeight - n.offsetHeight : 0; x = n.offsetLeft + e.clientX - x; y = n.offsetTop + e.clientY - y; - x= x < 0 ? 0 : x > w ? w : x; - y = y < 0 ? 0 : y > h ? h :y; + x = x < d ? d : x > w ? w : x; + y = y < t ? t : y > h ? h : y; n.style.left = x + 'px'; n.style.top = y + 'px'; }); From 18df91e4d1d901ebad0b0d7294bf1b88066b4e30 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:03:26 +0800 Subject: [PATCH 0430/1027] oops --- libs/dragndrop.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index 35d658e..10b1eee 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,19 +1,20 @@ (function() { - this.dragndrop = (n, {width, height}) => { + this.dragndrop = (n, {left, top}) => { var x, y, w, h; - var d = width ?? 0; - var t = height ?? 0; + var d = document.documentElement; + var l = left ?? 0; + var t = top ?? 0; n.draggable=true; n.addEventListener('dragstart', e => { x = e.clientX; y = e.clientY; }); n.addEventListener('dragend', e => { - w = document.documentElement.clientWidth > n.offsetWidth ? document.documentElement.clientWidth - n.offsetWidth : 0; - h = document.documentElement.clientHeight > n.offsetHeight ? document.documentElement.clientHeight - n.offsetHeight : 0; + w = d.clientWidth > n.offsetWidth ? d.clientWidth - n.offsetWidth : 0; + h = d.clientHeight > n.offsetHeight ? d.clientHeight - n.offsetHeight : 0; x = n.offsetLeft + e.clientX - x; y = n.offsetTop + e.clientY - y; - x = x < d ? d : x > w ? w : x; + x = x < l ? l : x > w ? w : x; y = y < t ? t : y > h ? h : y; n.style.left = x + 'px'; n.style.top = y + 'px'; From 9c275306f894bc3eac6b6cf0c9de813240ef1f34 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:08:12 +0800 Subject: [PATCH 0431/1027] Update dragndrop.js --- libs/dragndrop.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index 10b1eee..72c4ec0 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,21 +1,19 @@ (function() { - this.dragndrop = (n, {left, top}) => { + this.dragndrop = (n, {left = 0, top = 0, bottom = 0, right = 0}) => { var x, y, w, h; var d = document.documentElement; - var l = left ?? 0; - var t = top ?? 0; n.draggable=true; n.addEventListener('dragstart', e => { x = e.clientX; y = e.clientY; }); n.addEventListener('dragend', e => { - w = d.clientWidth > n.offsetWidth ? d.clientWidth - n.offsetWidth : 0; - h = d.clientHeight > n.offsetHeight ? d.clientHeight - n.offsetHeight : 0; + w = d.clientWidth > (n.offsetWidth + right) ? d.clientWidth - n.offsetWidth - right : 0; + h = d.clientHeight > (n.offsetHeight + bottom) ? d.clientHeight - n.offsetHeight - bottom : 0; x = n.offsetLeft + e.clientX - x; y = n.offsetTop + e.clientY - y; - x = x < l ? l : x > w ? w : x; - y = y < t ? t : y > h ? h : y; + x = x < left ? left : x > w ? w : x; + y = y < top ? top : y > h ? h : y; n.style.left = x + 'px'; n.style.top = y + 'px'; }); From 0a26ebdf0734d6ab5d9af0c888b15f404b242bd6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:09:46 +0800 Subject: [PATCH 0432/1027] Update dragndrop.js --- libs/dragndrop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index 72c4ec0..eccbd8d 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -8,8 +8,8 @@ y = e.clientY; }); n.addEventListener('dragend', e => { - w = d.clientWidth > (n.offsetWidth + right) ? d.clientWidth - n.offsetWidth - right : 0; - h = d.clientHeight > (n.offsetHeight + bottom) ? d.clientHeight - n.offsetHeight - bottom : 0; + w = d.clientWidth > n.offsetWidth + right ? d.clientWidth - n.offsetWidth - right : 0; + h = d.clientHeight > n.offsetHeight + bottom ? d.clientHeight - n.offsetHeight - bottom : 0; x = n.offsetLeft + e.clientX - x; y = n.offsetTop + e.clientY - y; x = x < left ? left : x > w ? w : x; From 38764fd3691f5b3359ea30ff1bd8bf8d6aca1526 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:17:54 +0800 Subject: [PATCH 0433/1027] use dragndrop.js --- SpeedRunHelper.user.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index e3b1668..247fb36 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,10 +1,11 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 2.19 +// @version 2.20 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-bppXwb8qd91C8TSgkTTVB2f7bzRmRWPPPO1Sf1OpEb4= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.scorecardresearch.com/*", "action": "cancel"} @@ -13,12 +14,11 @@ 'use strict'; var logger = {}; var style = {}; -var offset; var css = document.createElement('style'); css.innerHTML = '#widget {display: none !important;}\ #centerwidget {width: 100% !important;}\ -.speedrun-window {position: fixed; width: 1280px; height: 740px; z-index: 999;}\ +.speedrun-window {position: fixed; width: 1280px; height: 740px; z-index: 999999;}\ .speedrun-window iframe {width: 1280px !important; height: 720px !important;}\ .speedrun-top {position: relative; background-color: #52698A; width: 100%; user-select: none; height: 20px;}\ .speedrun-title > * {display: inline-block; width: 25%;}\ @@ -28,7 +28,7 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-item:active {filter: opacity(30%);}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 30%; height: 20px; z-index: 99999;}\ .speedrun-minimum iframe {display: none !important;}\ -.speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px; height: ' + (outerHeight - 20) + 'px; z-index: 99999;}\ +.speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px; height: ' + (outerHeight - 20) + 'px; z-index: 999999;}\ .speedrun-maximum iframe {width: 100% !important; height: calc(100% - 20px) !important;}\ #speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ .speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; @@ -84,9 +84,10 @@ function createRecordWindow(id, title, content) { 🔲\ \ '; + style[id] = container.style.cssText = 'top: ' + (130 + container.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + container.idx * 30) + 'px;'; + dragndrop(container, {top: document.querySelector('nav').parentNode.offsetHeight}); document.body.appendChild(container); container.appendChild(content); - style[id] = container.style.cssText = 'top: ' + (130 + container.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + container.idx * 30) + 'px;'; container.querySelector('#speedrun-minimum').addEventListener('click', event => { container.classList.add('speedrun-minimum'); container.classList.remove('speedrun-maximum'); @@ -104,14 +105,12 @@ function createRecordWindow(id, title, content) { container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); }); + container.addEventListener('dragend', event => { + if (container.className === 'speedrun-window') { + style[id] = container.style.cssText; + } + else { + container.style.cssText = ''; + } + }); } - -document.addEventListener('dragstart', event => { - offset = { top: event.clientY, left: event.clientX }; -}); -document.addEventListener('dragend', event => { - if (event.target.className === 'speedrun-window') { - var id = event.target.id.slice(event.target.id.indexOf('-') + 1); - style[id] = event.target.style.cssText = 'top: ' + (event.target.offsetTop + event.clientY - offset.top) + 'px; left: ' + (event.target.offsetLeft + event.clientX - offset.left) + 'px;'; - } -}); From 35761b7d5b902c5cad212f795fea1c4771fece40 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:19:50 +0800 Subject: [PATCH 0434/1027] use dragndrop.js --- RawMangaAssistant.user.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 50065dc..9036080 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,8 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-6gpigHvgEesYm635dyvOCRUHcXRFAaRj9X0BfEmJ+rs= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-bppXwb8qd91C8TSgkTTVB2f7bzRmRWPPPO1Sf1OpEb4= // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest @@ -63,7 +64,6 @@ var images; var watching; aria2 = {...aria2, ...GM_getValue('aria2', {jsonrpc: 'http://localhost:6800/jsonrpc', secret: ''})}; var options = GM_getValue('options', {menu: 'on', top: 300, left: 150}); -var visual = {height: document.documentElement.clientHeight, width: document.documentElement.clientWidth}; var offset; var warning; var headers = {'Cookie': document.cookie, 'Referer': location.href, 'User-Agent': navigator.userAgent}; @@ -224,7 +224,6 @@ button.id = 'assistant_button'; button.innerHTML = '🖱️'; button.className = 'menuOverlay assistantMenu'; button.style.cssText = 'top: ' + options.top + 'px; left: ' + options.left + 'px; text-align: center; vertical-align: middle; width: 42px; height: 42px; border: 1px solid darkviolet;'; -button.draggable = true; button.addEventListener('click', event => { container.style.display = 'block'; }); @@ -235,18 +234,10 @@ container.style.cssText = 'top: ' + options.top + 'px; left: ' + (options.left + document.body.append(button, container); // Draggable button and menu -button.addEventListener('dragstart', event => { - offset = {top: event.clientY, left: event.clientX}; -}); +dragndrop(button); button.addEventListener('dragend', event => { - var height = visual.height - button.offsetHeight; - var width = visual.width - button.offsetWidth; - var top = options.top + event.clientY - offset.top; - var left = options.left + event.clientX - offset.left; - options.top = top < 0 ? 0 : top > height ? height : top; - options.left = left < 0 ? 0 : left > width ? width : left; - button.style.top = options.top + 'px'; - button.style.left = options.left + 'px'; + options.top = button.offsetTop; + options.left = button.offsetLeft; container.style.top = button.offsetTop + 'px'; container.style.left = button.offsetLeft + button.offsetWidth + 'px'; GM_setValue('options', options); @@ -478,6 +469,6 @@ function notification(action, status, url) { function align_notification() { document.querySelectorAll('#assistant_caution').forEach((element, index) => { element.style.top = index * (element.offsetHeight + 5) + 10 + 'px'; - element.style.left = (visual.width - element.offsetWidth) / 2 + 'px'; + element.style.left = (document.documentElement.clientWidth - element.offsetWidth) / 2 + 'px'; }); } From d8d961fa3a6a43af879c86432fe9af5bafa3a7e4 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:28:41 +0800 Subject: [PATCH 0435/1027] Update dragndrop.js --- libs/dragndrop.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index eccbd8d..c631075 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -1,21 +1,22 @@ (function() { - this.dragndrop = (n, {left = 0, top = 0, bottom = 0, right = 0}) => { + this.dragndrop = ({node, top = 0, right = 0, bottom = 0, left = 0}, c) => { var x, y, w, h; var d = document.documentElement; - n.draggable=true; - n.addEventListener('dragstart', e => { - x = e.clientX; + node.draggable=true; + node.addEventListener('dragstart', e => { y = e.clientY; + x = e.clientX; }); - n.addEventListener('dragend', e => { - w = d.clientWidth > n.offsetWidth + right ? d.clientWidth - n.offsetWidth - right : 0; - h = d.clientHeight > n.offsetHeight + bottom ? d.clientHeight - n.offsetHeight - bottom : 0; - x = n.offsetLeft + e.clientX - x; - y = n.offsetTop + e.clientY - y; - x = x < left ? left : x > w ? w : x; + node.addEventListener('dragend', e => { + h = d.clientHeight > node.offsetHeight + bottom ? d.clientHeight - node.offsetHeight - bottom : 0; + w = d.clientWidth > node.offsetWidth + right ? d.clientWidth - node.offsetWidth - right : 0; + y = node.offsetTop + e.clientY - y; + x = node.offsetLeft + e.clientX - x; y = y < top ? top : y > h ? h : y; - n.style.left = x + 'px'; - n.style.top = y + 'px'; + x = x < left ? left : x > w ? w : x; + node.style.top = y + 'px'; + node.style.left = x + 'px'; + typeof c === 'function' ? c(y, x) : null; }); }; })(); From 37d370d54eb0837e47c6a2fe3147ec2250ca181b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:29:32 +0800 Subject: [PATCH 0436/1027] oops --- RawMangaAssistant.user.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 9036080..2a93f04 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.5 +// @version 6.6 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -17,7 +17,7 @@ // @match *://mangameta.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo= -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-bppXwb8qd91C8TSgkTTVB2f7bzRmRWPPPO1Sf1OpEb4= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-lSdnlkrnwtdX4Slk17sO7+ooQ7oQYyI0ZjxjBv0wRAg= // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest @@ -234,12 +234,10 @@ container.style.cssText = 'top: ' + options.top + 'px; left: ' + (options.left + document.body.append(button, container); // Draggable button and menu -dragndrop(button); -button.addEventListener('dragend', event => { - options.top = button.offsetTop; - options.left = button.offsetLeft; - container.style.top = button.offsetTop + 'px'; - container.style.left = button.offsetLeft + button.offsetWidth + 'px'; +dragndrop({node: button}, (top, left) => { + options = {...options, top, left}; + container.style.top = top + 'px'; + container.style.left = left + button.offsetWidth + 'px'; GM_setValue('options', options); }); document.addEventListener('click', event => { From 1bf4d577563b89aedadc20afab4b58fe142e6b19 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 11:39:58 +0800 Subject: [PATCH 0437/1027] Update SpeedRunHelper.user.js --- SpeedRunHelper.user.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 247fb36..6a4f334 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -5,7 +5,7 @@ // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-bppXwb8qd91C8TSgkTTVB2f7bzRmRWPPPO1Sf1OpEb4= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-lSdnlkrnwtdX4Slk17sO7+ooQ7oQYyI0ZjxjBv0wRAg= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.scorecardresearch.com/*", "action": "cancel"} @@ -85,7 +85,6 @@ function createRecordWindow(id, title, content) { \ '; style[id] = container.style.cssText = 'top: ' + (130 + container.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + container.idx * 30) + 'px;'; - dragndrop(container, {top: document.querySelector('nav').parentNode.offsetHeight}); document.body.appendChild(container); container.appendChild(content); container.querySelector('#speedrun-minimum').addEventListener('click', event => { @@ -105,7 +104,7 @@ function createRecordWindow(id, title, content) { container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); }); - container.addEventListener('dragend', event => { + dragndrop({node: container, top: document.querySelector('nav').parentNode.offsetHeight}, () => { if (container.className === 'speedrun-window') { style[id] = container.style.cssText; } From da474f32c4fccf65b8d75561a973815445140826 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:18:23 +0800 Subject: [PATCH 0438/1027] Update aria2request.md --- libs/HowToUse/aria2request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/HowToUse/aria2request.md b/libs/HowToUse/aria2request.md index 60f5d09..0d845d0 100644 --- a/libs/HowToUse/aria2request.md +++ b/libs/HowToUse/aria2request.md @@ -2,7 +2,7 @@ ### HTML ```HTML + integrity="sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo=" crossorigin="anonymous"/> ``` ### TamperMonkey ```javascript From ad8fd27c0a61e8ff349cba27e0c57c89d114dcdf Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:18:31 +0800 Subject: [PATCH 0439/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index 316a7e1..5e8d1de 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -2,7 +2,7 @@ ### HTML ```HTML + integrity="sha256-4W7nOCP6di9pmO+yv1Ta633VGIocNHeGZDwkMIjNiAo=" crossorigin="anonymous"/> ``` ### TamperMonkey ```javascript From dd924c72dc5a8e2308521bdc7148b50b7ad99da0 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:22:42 +0800 Subject: [PATCH 0440/1027] Update aria2request.md --- libs/HowToUse/aria2request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/HowToUse/aria2request.md b/libs/HowToUse/aria2request.md index 0d845d0..60f5d09 100644 --- a/libs/HowToUse/aria2request.md +++ b/libs/HowToUse/aria2request.md @@ -2,7 +2,7 @@ ### HTML ```HTML ``` ### TamperMonkey ```javascript From 4eba52a7c34b377051edf78753ca44449ff097ee Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:22:48 +0800 Subject: [PATCH 0441/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index 5e8d1de..316a7e1 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -2,7 +2,7 @@ ### HTML ```HTML ``` ### TamperMonkey ```javascript From 880fb5cb136461b19f5d6ff83a5d3b64c200c648 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:30:04 +0800 Subject: [PATCH 0442/1027] add dragndrop.js --- libs/HowToUse/dragndrop.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libs/HowToUse/dragndrop.md diff --git a/libs/HowToUse/dragndrop.md b/libs/HowToUse/dragndrop.md new file mode 100644 index 0000000..1c13ee9 --- /dev/null +++ b/libs/HowToUse/dragndrop.md @@ -0,0 +1,36 @@ +## How to implement +### HTML +```HTML + +``` +### TamperMonkey +```javascript +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-lSdnlkrnwtdX4Slk17sO7+ooQ7oQYyI0ZjxjBv0wRAg= +``` +## Syntax +```javascript +dragndrop(object, callback); +``` +### `object` +An object containing information to append drag'n'drop event for an element `{ node, top, right, bottom, left }` +#### node `*required` +The target DOM node +#### top `Optional` +The offset of top `integer`, `default: 0` +#### right `Optional` +The offset of right `integer`, `default: 0` +#### bottom` `Optional` +The offset of bottom `integer`, `default: 0` +#### left `Optional` +The offset of left `integer`, `default: 0` +### `callback` `function` `Optional` +A callback function with +#### binary +An `array` of text of the result +#### blob +A `blob` object of the result +#### text +A `string` of the result +#### saveAs(filename) `function` +Save the result into a local file. If **filename** is not defined, default filename is `metalink` From e706b8b2c88909ef16fea0a9551eec701ccceac3 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:33:49 +0800 Subject: [PATCH 0443/1027] Update dragndrop.js --- libs/dragndrop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/dragndrop.js b/libs/dragndrop.js index c631075..02d7ac4 100644 --- a/libs/dragndrop.js +++ b/libs/dragndrop.js @@ -16,7 +16,7 @@ x = x < left ? left : x > w ? w : x; node.style.top = y + 'px'; node.style.left = x + 'px'; - typeof c === 'function' ? c(y, x) : null; + if (typeof c === 'function') { c(y, x); } }); }; })(); From d3c30e634c319a078fe41cf445e04242ebacf32a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:34:24 +0800 Subject: [PATCH 0444/1027] Update dragndrop.md --- libs/HowToUse/dragndrop.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libs/HowToUse/dragndrop.md b/libs/HowToUse/dragndrop.md index 1c13ee9..47ca900 100644 --- a/libs/HowToUse/dragndrop.md +++ b/libs/HowToUse/dragndrop.md @@ -2,11 +2,11 @@ ### HTML ```HTML + integrity="sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA=" crossorigin="anonymous"> ``` ### TamperMonkey ```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-lSdnlkrnwtdX4Slk17sO7+ooQ7oQYyI0ZjxjBv0wRAg= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= ``` ## Syntax ```javascript @@ -20,17 +20,14 @@ The target DOM node The offset of top `integer`, `default: 0` #### right `Optional` The offset of right `integer`, `default: 0` -#### bottom` `Optional` +#### bottom `Optional` The offset of bottom `integer`, `default: 0` #### left `Optional` The offset of left `integer`, `default: 0` ### `callback` `function` `Optional` -A callback function with -#### binary -An `array` of text of the result -#### blob -A `blob` object of the result -#### text -A `string` of the result -#### saveAs(filename) `function` -Save the result into a local file. If **filename** is not defined, default filename is `metalink` +A callback function with new position +```javascript +function (top, left) { + // Your code here +} +``` From 50817b8433c344fd97bd82c9f66e3deab6b2f43d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:34:43 +0800 Subject: [PATCH 0445/1027] Update RawMangaAssistant.user.js --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 2a93f04..189561d 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -17,7 +17,7 @@ // @match *://mangameta.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo= -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-lSdnlkrnwtdX4Slk17sO7+ooQ7oQYyI0ZjxjBv0wRAg= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest From 034eedb63da5e1c0aa7663c66e9ee5263a033389 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 2 Jan 2022 12:34:50 +0800 Subject: [PATCH 0446/1027] Update SpeedRunHelper.user.js --- SpeedRunHelper.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 6a4f334..f980612 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -5,7 +5,7 @@ // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-lSdnlkrnwtdX4Slk17sO7+ooQ7oQYyI0ZjxjBv0wRAg= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.scorecardresearch.com/*", "action": "cancel"} From 3ec9338fa2559925e56f5da3e1af43a7be3d0ba9 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:34:20 +0800 Subject: [PATCH 0447/1027] Update metalink4.js --- libs/metalink4.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/metalink4.js b/libs/metalink4.js index 8e5e4f2..72c3d74 100644 --- a/libs/metalink4.js +++ b/libs/metalink4.js @@ -1,6 +1,6 @@ (function() { this.toMetalink4 = i => { - var a = ['', '', ...(Array.isArray(i) ? i : [i]).map(m), '']; + var a = ['', '', ...i.map(m), '']; var b = new Blob(a, {type: 'application/metalink+xml; charset=utf-8'}); return { binary: a, text: a.join(''), blob: b, saveAs: n => s(b, n) }; } From 31d5fafe0ba9fca7183e8153c95106e3328ac766 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:35:12 +0800 Subject: [PATCH 0448/1027] update metalink4.js --- NarouSyosetuManager.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 41dc815..bc75288 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -6,7 +6,7 @@ // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-4W7nOCP6di9pmO+yv1Ta633VGIocNHeGZDwkMIjNiAo= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-FsRx7H9t2YaHx6uutNQIARFvasjQ1mWyqSLvC1SLggU= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue From 26d2126f4ba7c3e1cf30b372de4aecb77b003c9b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:42:30 +0800 Subject: [PATCH 0449/1027] Update metalink4.js --- libs/metalink4.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/metalink4.js b/libs/metalink4.js index 72c3d74..371a5be 100644 --- a/libs/metalink4.js +++ b/libs/metalink4.js @@ -18,9 +18,9 @@ if (size) { f += '' + size + ''; } if (version) { f += '' + version + ''; } if (locale) { f += '' + locale + ''; } - if (hash) { if (Array.isArray(hash[0])) { hash.forEach(h => { f += '' + h[1] + ''; }); } else { f += '' + hash[1] + ''; } } - if (Array.isArray(url)) { url.forEach(u => { f += Array.isArray(u) ? '' + u[1] + '' : '' + u + ''; }); } else { f += '' + url + ''; } - if (metaurl) { if (Array.isArray(metaurl[0])) { metaurl.forEach(m => { f += '' + m[1] + ''; }); } else { f += '' + metaurl[1] + ''; } } + if (hash) { hash.forEach(h => { f += '' + h[1] + ''; }); } + url.forEach(u => { f += Array.isArray(u) ? '' + u[1] + '' : '' + u + ''; }); + if (metaurl) { metaurl.forEach(m => { f += '' + m[1] + ''; }); } return f += '
'; } })(); From d6719d9131e5bcdc019c1fff2489322f811b1d05 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:45:53 +0800 Subject: [PATCH 0450/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index 316a7e1..b3a7d67 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -2,26 +2,25 @@ ### HTML ```HTML + integrity="sha256-D+Tb/9BPMUZ/Bu2RTyHkWFiJkO0U2ihmWbZeBQ7BwTo=" crossorigin="anonymous"> ``` ### TamperMonkey ```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-4W7nOCP6di9pmO+yv1Ta633VGIocNHeGZDwkMIjNiAo= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-D+Tb/9BPMUZ/Bu2RTyHkWFiJkO0U2ihmWbZeBQ7BwTo= ``` ## Syntax ```javascript const meta4 = toMetalink4(input); ``` ### `input` -An object containing information to generate metalink file `{ name, size, version, locale, hash, url, metaurl }`, or\ -An array `[ { name, size, version, locale, hash, url, metaurl }, { name, size, version, locale, hash, url, metaurl }... ]` +An array of object `[ object0, object1, ... ]` +#### `object` +An object contains key `{url, name, size, version, locale, hash, metaurl }` #### url `*required` The download address of the file\ -String `url` to generate `https://sam.pl/e.zip`\ -Array `[ url0, url1... ] for multiple download addresses\ -Array `[ locale, url ]` to generate `https://sam.pl/e.zip`\ -Array `[ [ locale0, url0 ], [ locale1, url1 ]... ]` for multiple download addresses with locales -####`name `Optional` +Array `[ url0, url1... ]` to generate `https://sam.pl/e.zip` for multiple download addresses\ +Array `[ [ locale0, url0 ], [ locale1, url1 ]... ]` to generate `https://sam.pl/e.zip` for multiple download addresses with locales +#### name `Optional` The name of the file `` #### size `Optional` The size of the file `4279183` @@ -31,12 +30,10 @@ The version of the file `1.0.1` The language of the file `en` #### hash `Optional` The hash of the file\ -Array `[ type, hash ]` to generate `40a51...1e1d7`\ -Array `[ [ type0, hash0 ], [ type1, hash1 ]... ]` for multiple hashes +Array `[ [ type0, hash0 ], [ type1, hash1 ]... ]` to generate `40a51...1e1d7` for multiple hashes #### metaurl `Optional` The metaurl address of the file\ -Array `[ type, metaurl ]` to generate `https://sam.pl/e.zip.torrent`\ -Array `[ [ type0, metaurl0 ], [ type1, metaurl1 ]... ]` for multiple metaurl addresses +Array `[ [ type0, metaurl0 ], [ type1, metaurl1 ]... ]` to generate `https://sam.pl/e.zip.torrent` for multiple metaurl addresses ### `meta4` An object contains the result `{ binary, blob, text, saveAs }` #### binary From 8e242d14d4f03bc99a89022914d1b3da20739555 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:48:41 +0800 Subject: [PATCH 0451/1027] Update metalink4.js --- libs/metalink4.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/metalink4.js b/libs/metalink4.js index 371a5be..3b51f29 100644 --- a/libs/metalink4.js +++ b/libs/metalink4.js @@ -8,7 +8,7 @@ function s(b, n = 'metalink') { var s = document.createElement('a'); s.href = URL.createObjectURL(b); - s.download = n + '-' + new Date().toJSON().slice(0, -2).replace(/[T:\.\-]/g, '') + '.meta4'; + s.download = n + '-' + new Date().toJSON().slice(0, -2).replace(/[T:\.\-]/g, '_') + '.meta4'; s.click(); s.remove(); } From 2f1256f236c5990df034c3166578ebe5c548f5ac Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:53:42 +0800 Subject: [PATCH 0452/1027] Update metalink4.md --- libs/HowToUse/metalink4.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/HowToUse/metalink4.md b/libs/HowToUse/metalink4.md index b3a7d67..7621397 100644 --- a/libs/HowToUse/metalink4.md +++ b/libs/HowToUse/metalink4.md @@ -2,11 +2,11 @@ ### HTML ```HTML + integrity="sha256-sJFxO/Xi8lu3msbA2J9h46fvpHdacjfmKZ1xJ8AauDM=" crossorigin="anonymous"> ``` ### TamperMonkey ```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-D+Tb/9BPMUZ/Bu2RTyHkWFiJkO0U2ihmWbZeBQ7BwTo= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-sJFxO/Xi8lu3msbA2J9h46fvpHdacjfmKZ1xJ8AauDM= ``` ## Syntax ```javascript From f51c5b9cc622a3b0ea61a5a54a35f11e911140c8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:54:17 +0800 Subject: [PATCH 0453/1027] Update README.md --- libs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/README.md b/libs/README.md index fe2d3c7..ba55986 100644 --- a/libs/README.md +++ b/libs/README.md @@ -1,3 +1,4 @@ ## How to use #### [aria2request.js](HowToUse/aria2request.md) +#### [dragndrop.js](HowToUse/dragndrop.md) #### [metalink.js](HowToUse/metalink4.md) From ab4214ac2f248d7dab475ac0595ca3a49929d80e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:56:56 +0800 Subject: [PATCH 0454/1027] Delete README.md --- libs/README.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 libs/README.md diff --git a/libs/README.md b/libs/README.md deleted file mode 100644 index ba55986..0000000 --- a/libs/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## How to use -#### [aria2request.js](HowToUse/aria2request.md) -#### [dragndrop.js](HowToUse/dragndrop.md) -#### [metalink.js](HowToUse/metalink4.md) From 22f69655fad223d77492f5df708a83c5494fa533 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:57:20 +0800 Subject: [PATCH 0455/1027] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index accf4bc..980e7fc 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,9 @@ - Download `Tampermonkey` extension for `Chromium` or `Mozilla Firefox` - Click `Raw` then `Tampermonkey` will install the script automatically + +# Libraries + +#### [aria2request.js](HowToUse/aria2request.md) +#### [dragndrop.js](HowToUse/dragndrop.md) +#### [metalink.js](HowToUse/metalink4.md) From 5886265d896672cff8aac1b83f1ee45bcfeafe4e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:58:18 +0800 Subject: [PATCH 0456/1027] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 980e7fc..3b5033e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,6 @@ # Libraries -#### [aria2request.js](HowToUse/aria2request.md) -#### [dragndrop.js](HowToUse/dragndrop.md) -#### [metalink.js](HowToUse/metalink4.md) +#### [aria2request.js](libs/aria2request.md) +#### [dragndrop.js](libs/dragndrop.md) +#### [metalink.js](libs/metalink4.md) From 317da2023be7e2e56097caedfcf035947f79285e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:58:53 +0800 Subject: [PATCH 0457/1027] Rename libs/HowToUse/aria2request.md to libs/aria2request.md --- libs/{HowToUse => }/aria2request.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libs/{HowToUse => }/aria2request.md (100%) diff --git a/libs/HowToUse/aria2request.md b/libs/aria2request.md similarity index 100% rename from libs/HowToUse/aria2request.md rename to libs/aria2request.md From 9abb5dbbfebe8827ea4ed57dd246936b66804c18 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:58:59 +0800 Subject: [PATCH 0458/1027] Rename libs/HowToUse/dragndrop.md to libs/dragndrop.md --- libs/{HowToUse => }/dragndrop.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libs/{HowToUse => }/dragndrop.md (100%) diff --git a/libs/HowToUse/dragndrop.md b/libs/dragndrop.md similarity index 100% rename from libs/HowToUse/dragndrop.md rename to libs/dragndrop.md From b3820bca039dc1e9751aa8e8270654b8767ca6b2 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 5 Jan 2022 15:59:24 +0800 Subject: [PATCH 0459/1027] Rename libs/HowToUse/metalink4.md to libs/metalink4.md --- libs/{HowToUse => }/metalink4.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libs/{HowToUse => }/metalink4.md (100%) diff --git a/libs/HowToUse/metalink4.md b/libs/metalink4.md similarity index 100% rename from libs/HowToUse/metalink4.md rename to libs/metalink4.md From 0d1e47785f128811cd377d4957efeb03d7d1a44e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 8 Jan 2022 10:53:32 +0800 Subject: [PATCH 0460/1027] update klmag.net --- RawMangaAssistant.user.js | 61 +++++++++++++++------------------------ 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 189561d..b9f61ae 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -8,7 +8,7 @@ // @author jc3213 // @match *://ja.mangatoro.com/* // @match *://mikaraw.com/* -// @match *://klmanga.com/* +// @match *://klmag.net/* // @match *://rawdevart.com/* // @match *://manga1000.com/* // @match *://manga1001.com/* @@ -45,7 +45,7 @@ // @webRequest {"selector": "*downysewersettle.com/*", "action": "cancel"} // @webRequest {"selector": "*.exosrv.com/*", "action": "cancel"} // @webRequest {"selector": "*.bidgear.com/*", "action": "cancel"} -// klmanga.com +// klmag.net // @webRequest {"selector": "*.adtcdn.com/*", "action": "cancel"} // @webRequest {"selector": "*.greeter.me/*", "action": "cancel"} // @webRequest {"selector": "*.modoro360.com/*", "action": "cancel"} @@ -87,7 +87,6 @@ var message = { done: 'All %n% image urls have been sent to Aria2 RPC', error: 'Aria2 RPC failed to send request' }, - secret: 'Secret token updated, reloading page in 5 seconds', gotop: { label: 'Back to Top', }, @@ -97,8 +96,6 @@ var message = { menu: { label: 'Context Menu Mode' }, - submit: 'Submit', - cancel: 'Cancel', extract: { start: 'Extracting manga source', done: 'A total of %n% image urls has been extracted', @@ -119,11 +116,9 @@ var message = { aria2: { label: '发送至 Aria2 RPC', option: '设置 Aria2 RPC', - icon: '🖅', done: '全部 %n% 图像链接已发送至Aria2 RPC', error: 'Aria2 RPC 请求发生错误' }, - secret: '密钥已更新,5秒后自动刷新页面', gotop: { label: '回到顶部', }, @@ -133,8 +128,6 @@ var message = { menu: { label: '右键菜单模式', }, - submit: '确定', - cancel: '取消', extract: { start: '正在解析图像来源', done: '已成功解析全部 %n% 图像来源', @@ -159,7 +152,7 @@ var manga = { shortcut: ['#prev_chap', '#next_chap'], ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'] }, - 'klmanga.com': { + 'klmag.net': { image: 'img.chapter-img', lazyload: 'data-aload', title: {reg: /^(.+)\sChapter\s([^\s]+)/, sel: 'li.current > a', attr: 'title', tl: 1, ch: 2}, @@ -212,25 +205,27 @@ function extractMangaTitle(title = '') { // Create UI var css = document.createElement('style'); -css.innerHTML = '.menuOverlay {background-color: #fff; position: fixed; z-index: 999999999;}\ -.menuContainer {background-color: #fff; min-width: fit-content; max-width: 330px; border: 1px ridge darkblue; font-size: 14px;}\ -.assistantMenu {color: black; width: 190px; padding: 10px; height: 40px; display: block; user-select: none;}\ -.assistantMenu:hover {background-color: darkviolet !important; color: white; cursor: default;}\ -.assistantIcon {width: 30px; display: inline-block; text-align: center}'; +css.innerHTML = '#assistant_button, #assistant_container, #assistant_caution {background-color: #fff; color: #000; position: fixed; z-index: 999999999;}\ +#assistant_button {text-align: center; line-height: 42px; width: 42px !important; height: 42px !important; border: 1px solid darkviolet; top: ' + options.top + 'px; left: ' + options.left + 'px;}\ +#assistant_container {top: ' + options.top + 'px; left: ' + (options.left + 42) + 'px; display: none}\ +#assistant_container > * {background-color: #fff; width: 220px; border: 1px ridge darkblue; font-size: 14px;}\ +#assistant_container > * > *, #assistant_caution {line-height: 40px; height: 40px; user-select: none; display: grid; grid-template-columns: 40px auto;}\ +#assistant_container > * > * > *:first-child {text-align: center;}\ +#assistant_caution {font-size: 16px; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center;}\ +#assistant_caution > *:last-child {text-align: left; width: fit-content; padding-right: 10px;}\ +#assistant_button:hover, #assistant_container > * > *:hover {background-color: darkviolet !important; color: white !important;}'; document.body.appendChild(css); +var container = document.createElement('div'); +container.id = 'assistant_container'; + var button = document.createElement('span'); button.id = 'assistant_button'; button.innerHTML = '🖱️'; -button.className = 'menuOverlay assistantMenu'; -button.style.cssText = 'top: ' + options.top + 'px; left: ' + options.left + 'px; text-align: center; vertical-align: middle; width: 42px; height: 42px; border: 1px solid darkviolet;'; button.addEventListener('click', event => { container.style.display = 'block'; }); -var container = document.createElement('div'); -container.id = 'assistant_container'; -container.className = 'menuOverlay'; -container.style.cssText = 'top: ' + options.top + 'px; left: ' + (options.left + button.offsetWidth) + 'px; display: none'; + document.body.append(button, container); // Draggable button and menu @@ -246,11 +241,10 @@ document.addEventListener('click', event => { // Primary menus var downMenu = document.createElement('div'); -downMenu.innerHTML = '
💾' + i18n.save.label + '
\ -
📄' + i18n.copy.label + '
\ -
🖅' + i18n.aria2.label + '
\ -
⚙️' + i18n.aria2.option + '
'; -downMenu.className = 'menuContainer'; +downMenu.innerHTML = '
💾' + i18n.save.label + '
\ +
📄' + i18n.copy.label + '
\ +
🖅' + i18n.aria2.label + '
\ +
⚙️' + i18n.aria2.option + '
'; downMenu.style.display = 'none'; container.appendChild(downMenu); downMenu.querySelector('#download').addEventListener('click', event => { @@ -295,7 +289,7 @@ downMenu.querySelector('#aria2option').addEventListener('click', event => { function checkAria2Availability() { aria2.send('aria2.getGlobalOption').then(result => { folder = result.dir + extractMangaTitle(); - downMenu.querySelector('#aria2download').style.display = 'block'; + downMenu.querySelector('#aria2download').style.display = 'grid'; }).catch(error => { notification('aria2', 'error'); downMenu.querySelector('#aria2download').style.display = 'none'; @@ -304,8 +298,7 @@ function checkAria2Availability() { // Secondary menus var clickMenu = document.createElement('div'); -clickMenu.className = 'menuContainer'; -clickMenu.innerHTML = '
⬆️' + i18n.gotop.label + '
'; +clickMenu.innerHTML = '
⬆️' + i18n.gotop.label + '
'; clickMenu.querySelector('#scrolltop').addEventListener('click', event => { document.documentElement.scrollTop = 0; }); @@ -327,8 +320,7 @@ var switchWorker = { } }; var switchMenu = document.createElement('div'); -switchMenu.innerHTML = '
' + i18n.menu.label + '
'; -switchMenu.className = 'menuContainer'; +switchMenu.innerHTML = '
' + i18n.menu.label + '
'; switchMenu.querySelectorAll('.assistantMenu').forEach(switchHandler); switchMenu.addEventListener('click', event => { var name = event.target.getAttribute('name'); @@ -445,14 +437,9 @@ function appendShortcuts() { // Notifications function notification(action, status, url) { var warn = i18n[action][status] ?? i18n[action]; - var html = '⚠️' + warn.replace('%n%', '' + images.length + ''); - if (url) { - html += '

' + url + '

'; - } + var html = '⚠️' + warn.replace('%n%', '' + images.length + (url ? '

' + url + '

' : '') + '
') + '
'; var caution = document.createElement('div'); caution.id = 'assistant_caution'; - caution.className = 'menuOverlay assistantMenu'; - caution.style.cssText = 'width: fit-content; height: 50px; text-align: center; font-size: 16px; padding: 12px; border: 1px ridge darkviolet; border-radius: 10px;'; caution.innerHTML = html; document.body.appendChild(caution); align_notification(); From 3571efef416c7279add657235118ed737f756779 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 8 Jan 2022 10:55:04 +0800 Subject: [PATCH 0461/1027] Update RawMangaAssistant.user.js --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index b9f61ae..85c8e40 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -98,7 +98,7 @@ var message = { }, extract: { start: 'Extracting manga source', - done: 'A total of %n% image urls has been extracted', + done: 'A total of %n% image urls have been extracted', fail: 'Download function not available due to extraction failure', error: 'Can\'t be extracted image extension' } From b8fdb9f53dedefe15915def67b4bbee25ad55743 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 8 Jan 2022 11:30:31 +0800 Subject: [PATCH 0462/1027] update --- NarouSyosetuManager.user.js | 40 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index bc75288..dc8b9b1 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -6,7 +6,7 @@ // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-FsRx7H9t2YaHx6uutNQIARFvasjQ1mWyqSLvC1SLggU= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-sJFxO/Xi8lu3msbA2J9h46fvpHdacjfmKZ1xJ8AauDM= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue @@ -30,23 +30,18 @@ var scheduler = GM_getValue('scheduler', novelist.today); // UI作成関連 var css = document.createElement('style'); css.innerHTML = '.manager-button {background-color: #fff; text-align: center; vertical-align: middle; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; display: inline-block; cursor: pointer; font-weight: bold;}\ -.manager-button:hover {filter: opacity(60%);}\ -.manager-button:active {filter: opacity(30%);}\ +.manager-button:hover, .manager-shelf > * > *:hover {filter: opacity(75%);}\ +.manager-button:active,.manager-shelf > * > *:active {filter: opacity(45%);}\ .manager-checked {padding: 4px; border: 2px inset #00F;}\ .manager-container {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ .manager-menu :not(:first-child) {margin-left: 5px;}\ .manager-menu input {height: 20px;}\ .manager-container > div:nth-child(n+2) {margin-top: 5px;}\ .manager-shelf, .manager-logs {overflow-y: scroll; height: 552px;}\ -.manager-shelf div:nth-child(2n+1) {background-color: #DDD;}\ -.manager-shelf span { background-color: inherit; display: inline-block; padding: 5px; border: none; padding: 5px; font-weight: normal;}\ -.manager-shelf span:nth-child(1) {width: 100px;}\ -.manager-shelf span:nth-child(2) {width: 515px; text-align: left;}\ -.manager-shelf span:nth-child(3) {width: 100px;}\ -.manager-shelf input {width: 70px; padding: 5px;}\ -.manager-shelf div:nth-child(1) span:nth-child(4) {width: 100px;}\ -.manager-shelf div:nth-child(n+2) span:nth-child(4) {width: 90px; margin-right: 2px;}\ -.manager-shelf div:nth-child(1) span {height: 20px; overflow-y: hidden; text-align: center; margin: 0px; cursor: default; border: 1px solid #fff;}\ +.manager-shelf > * {display: grid; grid-template-columns: 100px calc(100% - 300px) 100px 100px; text-align: center;}\ +.manager-shelf > *:nth-child(2n+1):not(:first-child) * {background-color: #eee;}\ +.manager-shelf > *:not(:first-child) > *:nth-child(2) {text-align: left;}\ +.manager-shelf > *:not(:first-child) > *:nth-child(1) {line-height: 40px;}\ .notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff;}'; document.head.appendChild(css); @@ -105,7 +100,7 @@ container.querySelector('#mgr-btn-meta4').addEventListener('click', event => { var json = bookmark.map(book => { book.last = novelist.now; container.querySelector('#' + book.ncode).lastChild.innerHTML = generateTimeFormat(novelist.now); - return {url: 'https://pdfnovels.net/' + book.ncode + '/main.pdf', name: book.title + '.pdf', locale: 'ja'}; + return {url: ['https://pdfnovels.net/' + book.ncode + '/main.pdf'], name: book.title + '.pdf', locale: 'ja'}; }); toMetalink4(json).saveAs('小説家になろう書庫'); saveBookmarkButton(); @@ -167,10 +162,10 @@ function subscribeNcode(ncode, title) { function fancyTableItem(book, index) { var mybook = document.createElement('div'); mybook.id = book.ncode; - mybook.innerHTML = '' + book.ncode + '\ - ' + book.title + '\ - \ - ' + generateTimeFormat(book.last) + ''; + mybook.innerHTML = '' + book.ncode + '\ + ' + book.title + '\ + \ + ' + generateTimeFormat(book.last) + ''; container.querySelector('.manager-shelf').appendChild(mybook); mybook.querySelector('#mgr-bk-remove').addEventListener('click', event => { if (confirm('【 ' + book.title + ' 】を書庫から削除しますか?')) { @@ -191,16 +186,15 @@ function fancyTableItem(book, index) { } }); mybook.addEventListener('change', event => { - var day = parseInt(event.target.value); - book.next = day; + book.next = parseInt(event.target.value); saveBookmarkButton(); - if (day === 0) { - event.target.parentNode.title = '自動更新をしません'; + if (book.next === 0) { + event.target.title = '自動更新をしません'; myFancyLog(book.ncode, book.title, 'は更新しないように設定しました!'); } else { - event.target.parentNode.title = day + '日間隔で更新します'; - myFancyLog(book.ncode, book.title, 'は ' + day + ' 日間隔で更新するように設定しました!'); + event.target.title = book.next + '日間隔で更新します'; + myFancyLog(book.ncode, book.title, 'は ' + book.next + ' 日間隔で更新するように設定しました!'); } }); } From 33acf939a4c12ecc675cb3ebeba5fe50686fc4d6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 8 Jan 2022 12:30:58 +0800 Subject: [PATCH 0463/1027] Update NarouSyosetuManager.user.js --- NarouSyosetuManager.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index dc8b9b1..4e232da 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -30,8 +30,8 @@ var scheduler = GM_getValue('scheduler', novelist.today); // UI作成関連 var css = document.createElement('style'); css.innerHTML = '.manager-button {background-color: #fff; text-align: center; vertical-align: middle; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; display: inline-block; cursor: pointer; font-weight: bold;}\ -.manager-button:hover, .manager-shelf > * > *:hover {filter: opacity(75%);}\ -.manager-button:active,.manager-shelf > * > *:active {filter: opacity(45%);}\ +.manager-button:hover, .manager-shelf > *:not(:first-child) > *:hover {filter: opacity(75%);}\ +.manager-button:active,.manager-shelf > *:not(:first-child) > *:active {filter: opacity(45%);}\ .manager-checked {padding: 4px; border: 2px inset #00F;}\ .manager-container {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ .manager-menu :not(:first-child) {margin-left: 5px;}\ From afb85fb7696dc0331266919dcc2775adc00240fc Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 8 Jan 2022 14:11:42 +0800 Subject: [PATCH 0464/1027] better ui --- NyaaTorrentHelper.user.js | 75 ++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 44 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 989aed4..c716ada 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 5.2 +// @version 5.3 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -46,67 +46,52 @@ if (['502 Bad Gateway', '429 Too Many Requests'].includes(document.title)) { // Create UI var css= document.createElement('style'); -css.innerHTML = '.filter-button {background-color: #056b00; border: 1px solid black; color: #FFF; padding: 10px; cursor: pointer; user-select: none;}\ -.filter-buttonn:active {filter: opacity(30%);}\ -.filter-item {position: relative; padding: 2px;}\ -.filter-item > * {color: #fff; padding: 10px 5px; width: fit-content; border-radius: 3px; position: absolute; display: inline-block; text-decoration: none; vertical-align: middle;}\ -.filter-item > *:not(:first-child) {cursor: pointer; width: 60px; text-align: center; user-select: none;}\ -.filter-item *:not(:first-child):hover, filter-button:hover {filter: opacity(60%);}\ -.filter-item > *:nth-child(1) {background-color: #2bceec; overflow: hidden; z-index: 3213; width: 728px;}\ -.filter-item > *:nth-child(1):hover {min-width: fit-content;}\ -.filter-item > *:nth-child(2) {background-color: #ee1c1c; left: 733px;}\ -.filter-item > *:nth-child(3) {background-color: #0056b0; left: 797px;}\ -.filter-item > *:nth-child(4) {background-color: #056b00; left: 860px;}\ -.filter-item > *:nth-child(5) {background-color: #0005cc; left: 923px;}\ -.filter-preview {position: fixed; z-index: 3213;}'; +css.innerHTML = '#filter-menu {position: relative; top: 8px; display: grid; grid-template-columns: 180px 62px;}\ +#filter-menu button {background-color: #056b00;}\ +#filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; display: none; overflow-x: hidden; z-index: 9999999;}\ +#filter-list > * {display: grid; grid-template-columns: 700px 70px 70px 70px 70px; position: relative;}\ +#filter-list > * > * {padding: 10px 5px; margin: 1px; color: #fff; border-radius: 5px; text-decoration: none;}\ +#filter-list > * > *:not(:first-child, text) {text-align: center; cursor: pointer; user-select: none;}\ +#filter-list > * > *:nth-child(1) {background-color: #2bceec; overflow: hidden; z-index: 3213;}\ +#filter-list > * > *:nth-child(1):hover {min-width: fit-content;}\ +#filter-list > * > *:nth-child(2) {background-color: #ee1c1c;}\ +#filter-list > * > *:nth-child(3):not(text) {background-color: #0056b0;}\ +#filter-list > * > *:nth-child(4) {background-color: #056b00;}\ +#filter-list > * > *:nth-child(5) {background-color: #0005cc;}\ +#filter-preview {position: absolute; z-index: 3213;}'; document.head.appendChild(css); -var container = document.createElement('div'); -container.style.cssText = 'position: relative; top: 6px;'; -document.querySelector('#navbar').appendChild(container); - -var input = document.createElement('input'); -input.style.cssText = 'color: black; border: 1px solid black; padding: 5px; width: 180px; height: 38px;'; -input.placeholder = i18n.keyword; -input.addEventListener('keypress', event => { if (event.key === 'Enter') {button.click();} }); -container.appendChild(input); - -var button = document.createElement('span'); -button.className = 'filter-button'; -button.innerHTML = i18n.filter; -button.addEventListener('click', event => { - var keys = input.value.split(/[\|\/\\\+,:;\s]+/); +var menu = document.createElement('div'); +menu.id = 'filter-menu'; +menu.innerHTML = ''; +document.querySelector('#navbar').appendChild(menu); +menu.querySelector('input').addEventListener('keypress', event => event.key === 'Enter' && menu.querySelector('button').click()); +menu.querySelector('button').addEventListener('click', event => { + var keys = menu.querySelector('input').value.split(/[\|\/\\\+,:;\s]+/); if (filter && keys.join() === keyword.join()) { popup.style.display = 'none'; filter = false; } else { popup.innerHTML = ''; - popup.style.display = 'block'; - queue.forEach(data => { - if (keys.filter(key => data.name.includes(key)).length === keys.length) { - getFilterResult(data); - } - }); - popup.querySelectorAll('div').forEach((element, index) => { element.style.top = index * 40 + 'px'; }); + popup.style.cssText = 'left: ' + (document.documentElement.offsetWidth - 1000) / 2 + 'px; top: ' + document.querySelector('#navbar').offsetHeight + 'px; display: block'; + queue.forEach(data => keys.filter(key => data.name.includes(key)).length === keys.length && getFilterResult(data) ); keyword = keys; filter = true; } }); -container.appendChild(button); var popup = document.createElement('div'); -popup.style.cssText = 'position: fixed; left: calc(50% - 550px); background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; display: none; overflow-x: hidden;'; -container.appendChild(popup); +popup.id = 'filter-list'; +document.body.appendChild(popup); // Show filter result function getFilterResult(data) { var menu = document.createElement('div'); - menu.className = 'filter-item'; menu.innerHTML = '' + data.name + '\ - ' + i18n.preview + '\ - ' + i18n.torrent + '\ - ' + i18n.magnet + '\ + ' + i18n.preview + '' + + (data.torrent ? '' + i18n.torrent + '' : '') + + '' + i18n.magnet + '\ ' + i18n.copy + ''; popup.appendChild(menu); menu.querySelector('#preview').addEventListener('click', event => { @@ -114,7 +99,9 @@ function getFilterResult(data) { getPreviewHandler(data, {top: event.clientY, left: event.clientX}); }); menu.querySelector('#copy').addEventListener('click', event => { + event.target.innerText = '!'; navigator.clipboard.writeText(i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.image ? data.image : data.web ? data.web : '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet); + setTimeout(() => {event.target.innerText = i18n.copy;}, 1000); }); } @@ -209,8 +196,8 @@ function noValidPreview(data) { // Create preview function createPreview(data, mouse) { var image = document.createElement('img'); + image.id = 'filter-preview'; image.src = data.image; - image.className = 'filter-preview'; image.style.cssText = 'max-height: 800px; width: auto; top: ' + (mouse.top + 800 > innerHeight ? innerHeight - 800 : mouse.top) + 'px; left: ' + (mouse.left + 600 > innerWidth ? innerWidth - 600 : mouse.left) + 'px;'; image.addEventListener('click', event => image.remove()); document.body.appendChild(image); From 43594804b32718badc1a21021512da7487f85e96 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 8 Jan 2022 15:00:42 +0800 Subject: [PATCH 0465/1027] Update NyaaTorrentHelper.user.js --- NyaaTorrentHelper.user.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index c716ada..3905b89 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -20,7 +20,6 @@ var action = {}; // i18n Strings var messages = { 'en-US': { - filter: 'Filter', keyword: 'Keyword...', name: 'Name', preview: 'Preview', @@ -29,7 +28,6 @@ var messages = { copy: 'Copy' }, 'zh-CN': { - filter: '过滤', keyword: '关键词...', name: '名字', preview: '预览', @@ -46,8 +44,8 @@ if (['502 Bad Gateway', '429 Too Many Requests'].includes(document.title)) { // Create UI var css= document.createElement('style'); -css.innerHTML = '#filter-menu {position: relative; top: 8px; display: grid; grid-template-columns: 180px 62px;}\ -#filter-menu button {background-color: #056b00;}\ +css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin-top: 8px;}\ +#filter-menu button {background-color: #056b00; margin-top: -3px;}\ #filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; display: none; overflow-x: hidden; z-index: 9999999;}\ #filter-list > * {display: grid; grid-template-columns: 700px 70px 70px 70px 70px; position: relative;}\ #filter-list > * > * {padding: 10px 5px; margin: 1px; color: #fff; border-radius: 5px; text-decoration: none;}\ @@ -63,7 +61,7 @@ document.head.appendChild(css); var menu = document.createElement('div'); menu.id = 'filter-menu'; -menu.innerHTML = ''; +menu.innerHTML = ''; document.querySelector('#navbar').appendChild(menu); menu.querySelector('input').addEventListener('keypress', event => event.key === 'Enter' && menu.querySelector('button').click()); menu.querySelector('button').addEventListener('click', event => { From 7cec498b54429d65e02b723997db256bb0e511a1 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 9 Jan 2022 16:23:06 +0800 Subject: [PATCH 0466/1027] Update metalink4.md --- libs/metalink4.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/metalink4.md b/libs/metalink4.md index 7621397..728c638 100644 --- a/libs/metalink4.md +++ b/libs/metalink4.md @@ -18,8 +18,8 @@ An array of object `[ object0, object1, ... ]` An object contains key `{url, name, size, version, locale, hash, metaurl }` #### url `*required` The download address of the file\ -Array `[ url0, url1... ]` to generate `https://sam.pl/e.zip` for multiple download addresses\ -Array `[ [ locale0, url0 ], [ locale1, url1 ]... ]` to generate `https://sam.pl/e.zip` for multiple download addresses with locales +Array `[ url0, url1... ]` to generate `https://sam.pl/e.zip`\ +Array `[ [ locale0, url0 ], [ locale1, url1 ]... ]` to generate `https://sam.pl/e.zip` #### name `Optional` The name of the file `` #### size `Optional` @@ -30,10 +30,10 @@ The version of the file `1.0.1` The language of the file `en` #### hash `Optional` The hash of the file\ -Array `[ [ type0, hash0 ], [ type1, hash1 ]... ]` to generate `40a51...1e1d7` for multiple hashes +Array `[ [ type0, hash0 ], [ type1, hash1 ]... ]` to generate `40a51...1e1d7` #### metaurl `Optional` The metaurl address of the file\ -Array `[ [ type0, metaurl0 ], [ type1, metaurl1 ]... ]` to generate `https://sam.pl/e.zip.torrent` for multiple metaurl addresses +Array `[ [ type0, metaurl0 ], [ type1, metaurl1 ]... ]` to generate `https://sam.pl/e.zip.torrent` ### `meta4` An object contains the result `{ binary, blob, text, saveAs }` #### binary From 7985c3077fc209763335bc0b1c3f52b61001e8cc Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 9 Jan 2022 22:55:02 +0800 Subject: [PATCH 0467/1027] fixed invalid folder --- RawMangaAssistant.user.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 85c8e40..1d66e06 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.6 +// @version 6.7 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -200,7 +200,7 @@ function extractMangaTitle(title = '') { var result = watching.title.reg.exec(document.querySelector(watching.title.sel).getAttribute(watching.title.attr)); title += symbol + result[watching.title.tl] + symbol + result[watching.title.ch]; } - return title; + return title.replace(/[:\?\"\'\\\/]/g, '_'); } // Create UI @@ -230,10 +230,9 @@ document.body.append(button, container); // Draggable button and menu dragndrop({node: button}, (top, left) => { - options = {...options, top, left}; container.style.top = top + 'px'; container.style.left = left + button.offsetWidth + 'px'; - GM_setValue('options', options); + GM_setValue('options', {...options, top, left}); }); document.addEventListener('click', event => { container.style.display = button.contains(event.target) ? 'block' : 'none'; From cb596e85a4b5fed35317cf7d61177ace935923cb Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 10 Jan 2022 00:23:19 +0800 Subject: [PATCH 0468/1027] clean up and fixed contextmenu --- RawMangaAssistant.user.js | 109 +++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 61 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 1d66e06..e42c4e1 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.7 +// @version 6.8 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -207,17 +207,15 @@ function extractMangaTitle(title = '') { var css = document.createElement('style'); css.innerHTML = '#assistant_button, #assistant_container, #assistant_caution {background-color: #fff; color: #000; position: fixed; z-index: 999999999;}\ #assistant_button {text-align: center; line-height: 42px; width: 42px !important; height: 42px !important; border: 1px solid darkviolet; top: ' + options.top + 'px; left: ' + options.left + 'px;}\ -#assistant_container {top: ' + options.top + 'px; left: ' + (options.left + 42) + 'px; display: none}\ +#assistant_container {top: ' + options.top + 'px; left: ' + (options.left + 42) + 'px; display: none;}\ #assistant_container > * {background-color: #fff; width: 220px; border: 1px ridge darkblue; font-size: 14px;}\ +#assistant_container > *:nth-child(-n+2), #assistant_container data {display: none;}\ +#assistant_container.extract > *:nth-child(1), #assistant_container.aria2 > *:nth-child(2), #assistant_container .checked data {display: block;}\ #assistant_container > * > *, #assistant_caution {line-height: 40px; height: 40px; user-select: none; display: grid; grid-template-columns: 40px auto;}\ #assistant_container > * > * > *:first-child {text-align: center;}\ #assistant_caution {font-size: 16px; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center;}\ #assistant_caution > *:last-child {text-align: left; width: fit-content; padding-right: 10px;}\ #assistant_button:hover, #assistant_container > * > *:hover {background-color: darkviolet !important; color: white !important;}'; -document.body.appendChild(css); - -var container = document.createElement('div'); -container.id = 'assistant_container'; var button = document.createElement('span'); button.id = 'assistant_button'; @@ -225,8 +223,17 @@ button.innerHTML = '🖱️'; button.addEventListener('click', event => { container.style.display = 'block'; }); +document.addEventListener('click', event => { + container.style.display = button.contains(event.target) ? 'block' : 'none'; +}); -document.body.append(button, container); +var container = document.createElement('div'); +container.id = 'assistant_container'; +container.innerHTML = '
💾' + i18n.save.label + '
\ +
📄' + i18n.copy.label + '
\ +
🖅' + i18n.aria2.label + '
\ +
⚙️' + i18n.aria2.option + '
\ +
⬆️' + i18n.gotop.label + '
'; // Draggable button and menu dragndrop({node: button}, (top, left) => { @@ -234,19 +241,8 @@ dragndrop({node: button}, (top, left) => { container.style.left = left + button.offsetWidth + 'px'; GM_setValue('options', {...options, top, left}); }); -document.addEventListener('click', event => { - container.style.display = button.contains(event.target) ? 'block' : 'none'; -}); -// Primary menus -var downMenu = document.createElement('div'); -downMenu.innerHTML = '
💾' + i18n.save.label + '
\ -
📄' + i18n.copy.label + '
\ -
🖅' + i18n.aria2.label + '
\ -
⚙️' + i18n.aria2.option + '
'; -downMenu.style.display = 'none'; -container.appendChild(downMenu); -downMenu.querySelector('#download').addEventListener('click', event => { +container.querySelector('#download').addEventListener('click', event => { urls.forEach((url, index) => { GM_xmlhttpRequest({ method: 'GET', @@ -266,19 +262,24 @@ downMenu.querySelector('#download').addEventListener('click', event => { }); }); }) -downMenu.querySelector('#clipboard').addEventListener('click', event => { +container.querySelector('#clipboard').addEventListener('click', event => { navigator.clipboard.writeText(urls.join('\n')); notification('copy', 'done'); }); +container.querySelector('#scrolltop').addEventListener('click', event => { + document.documentElement.scrollTop = 0; +}); +document.body.append(button, container, css); + // Aria2 Menuitems -downMenu.querySelector('#aria2download').addEventListener('click', event => { +container.querySelector('#aria2download').addEventListener('click', event => { urls.forEach((url, index) => aria2.send('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]).then(result => { if (index === urls.length - 1) { notification('aria2', 'done'); } })); }); -downMenu.querySelector('#aria2option').addEventListener('click', event => { +container.querySelector('#aria2option').addEventListener('click', event => { aria2.jsonrpc = prompt('Aria2 JSONRPC URI', aria2.jsonrpc) ?? aria2.jsonrpc; aria2.secret = prompt('Aria2 Secret Token', aria2.secret) ?? aria2.secret; GM_setValue('aria2', aria2); @@ -288,24 +289,15 @@ downMenu.querySelector('#aria2option').addEventListener('click', event => { function checkAria2Availability() { aria2.send('aria2.getGlobalOption').then(result => { folder = result.dir + extractMangaTitle(); - downMenu.querySelector('#aria2download').style.display = 'grid'; - }).catch(error => { - notification('aria2', 'error'); - downMenu.querySelector('#aria2download').style.display = 'none'; - }); + container.classList.add('aria2'); + }).catch(error => notification('aria2', 'error')); } -// Secondary menus -var clickMenu = document.createElement('div'); -clickMenu.innerHTML = '
⬆️' + i18n.gotop.label + '
'; -clickMenu.querySelector('#scrolltop').addEventListener('click', event => { - document.documentElement.scrollTop = 0; -}); -container.appendChild(clickMenu); - // Switchable Menus -var switchWorker = { - menu: { +var switchMenu = document.createElement('div'); +[ + { + name: 'menu', on: () => { button.style.display = 'none'; document.addEventListener('contextmenu', contextMenuHandler); @@ -317,31 +309,32 @@ var switchWorker = { container.style.left = button.offsetLeft + button.offsetWidth + 'px'; } } -}; -var switchMenu = document.createElement('div'); -switchMenu.innerHTML = '
' + i18n.menu.label + '
'; -switchMenu.querySelectorAll('.assistantMenu').forEach(switchHandler); -switchMenu.addEventListener('click', event => { - var name = event.target.getAttribute('name'); - options[name] = options[name] === 'on' ? 'off' : 'on'; - switchHandler(event.target); - GM_setValue('options', options); +].forEach(({name, on, off}) => { + var menu = document.createElement('div'); + menu.setAttribute('name', name); + menu.innerHTML = '' + i18n.menu.label + ''; + menu.addEventListener('click', event => { + options[name] = options[name] === 'on' ? 'off' : 'on'; + switchHandler(menu, name, on, off); + GM_setValue('options', options); + }); + switchHandler(menu, name, on, off); + switchMenu.appendChild(menu); }); container.appendChild(switchMenu); -function switchHandler(item) { - var name = item.getAttribute('name'); +function switchHandler(menu, name, on, off) { if (options[name] === 'on') { - switchWorker[name].on(); - item.querySelector('.assistantIcon').innerHTML = '✅'; + on(); + menu.classList.add('checked'); } else { - switchWorker[name].off(); - item.querySelector('.assistantIcon').innerHTML = ''; + off(); + menu.classList.remove('checked'); } } function contextMenuHandler(event) { - if (event.target.id === 'assistant_aria2' || event.shiftKey) { + if (event.shiftKey) { return; } event.preventDefault(); @@ -379,10 +372,9 @@ function extractImage() { observer = setInterval(() => { if (images.length === urls.length + fail.length + logo.length) { warning.remove(); - downMenu.style.display = 'block'; clearInterval(observer); if (fail.length === 0) { - downMenu.style.display = 'block'; + container.classList.add('extract'); notification('extract', 'done'); } else { @@ -422,14 +414,9 @@ function extractImage() { function appendShortcuts() { var button = Array.isArray(watching.shortcut) ? watching.shortcut.map(item => document.querySelector(item)) : document.querySelectorAll(watching.shortcut); document.addEventListener('keydown', event => { - if (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA') { - return; - } var index = ['ArrowLeft', 'ArrowRight'].indexOf(event.key); var shortcut = button[index]; - if (shortcut) { - shortcut.click(); - } + shortcut && shortcut.click(); }); } From 4d073b454aee3607607f21ec6508748ede19624a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 10 Jan 2022 00:30:38 +0800 Subject: [PATCH 0469/1027] fixed download folder --- RawMangaAssistant.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index e42c4e1..5c20d08 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -200,7 +200,7 @@ function extractMangaTitle(title = '') { var result = watching.title.reg.exec(document.querySelector(watching.title.sel).getAttribute(watching.title.attr)); title += symbol + result[watching.title.tl] + symbol + result[watching.title.ch]; } - return title.replace(/[:\?\"\'\\\/]/g, '_'); + return title.replace(/[:\?\"\']/g, '_'); } // Create UI @@ -234,6 +234,7 @@ container.innerHTML = '
💾' + i18n.s
🖅' + i18n.aria2.label + '
\
⚙️' + i18n.aria2.option + '
\
⬆️' + i18n.gotop.label + '
'; +document.body.append(button, container, css); // Draggable button and menu dragndrop({node: button}, (top, left) => { @@ -269,7 +270,6 @@ container.querySelector('#clipboard').addEventListener('click', event => { container.querySelector('#scrolltop').addEventListener('click', event => { document.documentElement.scrollTop = 0; }); -document.body.append(button, container, css); // Aria2 Menuitems container.querySelector('#aria2download').addEventListener('click', event => { From fbe27f860705fc5a8cc93458601c98c3d42bc482 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 10 Jan 2022 10:07:19 +0800 Subject: [PATCH 0470/1027] clean up --- RawMangaAssistant.user.js | 49 +++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 5c20d08..a710533 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.8 +// @version 6.9 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -58,7 +58,6 @@ var urls = []; var fail = []; var logo = []; -var folder; var observer; var images; var watching; @@ -83,9 +82,8 @@ var message = { }, aria2: { label: 'Send to Aria2 RPC', - option: 'Options Aria2 RPC', done: 'All %n% image urls have been sent to Aria2 RPC', - error: 'Aria2 RPC failed to send request' + error: 'JSONRPC: Failed to send request' }, gotop: { label: 'Back to Top', @@ -115,9 +113,8 @@ var message = { }, aria2: { label: '发送至 Aria2 RPC', - option: '设置 Aria2 RPC', done: '全部 %n% 图像链接已发送至Aria2 RPC', - error: 'Aria2 RPC 请求发生错误' + error: 'JSONRPC: 请求错误<' }, gotop: { label: '回到顶部', @@ -210,7 +207,7 @@ css.innerHTML = '#assistant_button, #assistant_container, #assistant_caution {ba #assistant_container {top: ' + options.top + 'px; left: ' + (options.left + 42) + 'px; display: none;}\ #assistant_container > * {background-color: #fff; width: 220px; border: 1px ridge darkblue; font-size: 14px;}\ #assistant_container > *:nth-child(-n+2), #assistant_container data {display: none;}\ -#assistant_container.extract > *:nth-child(1), #assistant_container.aria2 > *:nth-child(2), #assistant_container .checked data {display: block;}\ +#assistant_container.extract > *:nth-child(-n+2), #assistant_container .checked data {display: block;}\ #assistant_container > * > *, #assistant_caution {line-height: 40px; height: 40px; user-select: none; display: grid; grid-template-columns: 40px auto;}\ #assistant_container > * > * > *:first-child {text-align: center;}\ #assistant_caution {font-size: 16px; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center;}\ @@ -231,8 +228,7 @@ var container = document.createElement('div'); container.id = 'assistant_container'; container.innerHTML = '
💾' + i18n.save.label + '
\
📄' + i18n.copy.label + '
\ -
🖅' + i18n.aria2.label + '
\ -
⚙️' + i18n.aria2.option + '
\ +
🖅' + i18n.aria2.label + '
\
⬆️' + i18n.gotop.label + '
'; document.body.append(button, container, css); @@ -273,26 +269,24 @@ container.querySelector('#scrolltop').addEventListener('click', event => { // Aria2 Menuitems container.querySelector('#aria2download').addEventListener('click', event => { - urls.forEach((url, index) => aria2.send('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]).then(result => { - if (index === urls.length - 1) { - notification('aria2', 'done'); - } - })); -}); -container.querySelector('#aria2option').addEventListener('click', event => { - aria2.jsonrpc = prompt('Aria2 JSONRPC URI', aria2.jsonrpc) ?? aria2.jsonrpc; - aria2.secret = prompt('Aria2 Secret Token', aria2.secret) ?? aria2.secret; - GM_setValue('aria2', aria2); - checkAria2Availability(); + var json; + var folder; + var request = () => { + aria2.send('aria2.getGlobalOption').then(result => { + folder = folder ?? result.dir + extractMangaTitle(); + json = json ?? urls.map((url, index) => ({method: 'aria2.addUri', params: [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]})); + aria2.multi(json).then(result => notification('aria2', 'done')); + }).catch(error => { + alert(i18n.aria2.error); + aria2.jsonrpc = prompt('Aria2 JSONRPC URI', aria2.jsonrpc) ?? aria2.jsonrpc; + aria2.secret = prompt('Aria2 Secret Token', aria2.secret) ?? aria2.secret; + GM_setValue('aria2', aria2); + request(); + }); + } + request(); }); -function checkAria2Availability() { - aria2.send('aria2.getGlobalOption').then(result => { - folder = result.dir + extractMangaTitle(); - container.classList.add('aria2'); - }).catch(error => notification('aria2', 'error')); -} - // Switchable Menus var switchMenu = document.createElement('div'); [ @@ -351,7 +345,6 @@ if (watching) { } images = document.querySelectorAll(watching.image); if (images.length > 0) { - checkAria2Availability(); extractImage(); if (watching.shortcut) { appendShortcuts(); From 396622866308bfb09a04f8ec60f6e873343764b6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 10 Jan 2022 10:28:38 +0800 Subject: [PATCH 0471/1027] Update RawMangaAssistant.user.js --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index a710533..12cf5cb 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -114,7 +114,7 @@ var message = { aria2: { label: '发送至 Aria2 RPC', done: '全部 %n% 图像链接已发送至Aria2 RPC', - error: 'JSONRPC: 请求错误<' + error: 'JSONRPC: 请求错误' }, gotop: { label: '回到顶部', From 49cfdfeb6a819551c0b8ae64c93220e199b0309c Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 10 Jan 2022 14:07:33 +0800 Subject: [PATCH 0472/1027] Update BilibiliVideoDownloader.user.js --- BilibiliVideoDownloader.user.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index eb43b3d..a0f30f6 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -29,19 +29,18 @@ var format = { }; var title = ''; -var mybox = document.createElement('div') +var menu = document.createElement('div'); +menu.id = 'download-box'; var thumb = document.createElement('div'); var video = document.createElement('div'); var audio = document.createElement('div'); -mybox.className = 'mybox'; -mybox.append(thumb, video, audio); +menu.append(thumb, video, audio); var css = document.createElement('style'); -css.innerHTML = '.mybox {position: relative; top: -5px; left: 10px; height: 0px; z-index: 99}\ -.mybox > div {display: inline-block; margin-left: 3px; vertical-align: top; height: 38px; overflow-y: hidden;}\ -.mybox > div:hover {height: max-content;}\ -.mybox > div > a {background-color: #c26; color: #fff; display: block; margin-top: 1px; height: 16px; line-height: 16px; padding: 10px; text-align: center;}\ -.mybox > div > a:hover {background-color: #26c;}'; +css.innerHTML = '#download-box > * {position: relative; display: inline-block; margin: -5px 1px 5px; height: 38px; overflow-y: hidden; vertical-align: top;}\ +#download-box > *:hover {height: max-content; z-index: 999999;}\ +#download-box a {background-color: #c26; color: #fff; display: block; margin-top: 1px; height: 16px; line-height: 16px; padding: 10px; text-align: center;}\ +#download-box a:hover {background-color: #26c;}'; setTimeout(() => { var player = document.querySelector('video') ?? document.querySelector('bwp-video'); @@ -65,7 +64,7 @@ setTimeout(() => { player.addEventListener('loadstart', () => { thumb.innerHTML = video.innerHTML = audio.innerHTML = title = ''; }); - toolbar.append(mybox, css); + toolbar.append(menu, css); }, 1500); function bilibiliVideoTitle(name) { From 5bdba1c87ff497041581621f989c4974bf32c414 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 11 Jan 2022 20:12:13 +0800 Subject: [PATCH 0473/1027] fixed maximum --- SpeedRunHelper.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index f980612..1553cc3 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 2.20 +// @version 3.0 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -26,9 +26,9 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-item {background-color: #fff; cursor: pointer; display: inline-block; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 2px;}\ .speedrun-item:hover {filter: opacity(60%);}\ .speedrun-item:active {filter: opacity(30%);}\ -.speedrun-minimum {bottom: 0px; left: 0px; width: 30%; height: 20px; z-index: 99999;}\ +.speedrun-minimum {bottom: 0px; left: 0px; width: 25% !important; height: 20px !important; z-index: 99999;}\ .speedrun-minimum iframe {display: none !important;}\ -.speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px; height: ' + (outerHeight - 20) + 'px; z-index: 999999;}\ +.speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px !important; height: ' + (outerHeight - 60) + 'px !important; z-index: 999999;}\ .speedrun-maximum iframe {width: 100% !important; height: calc(100% - 20px) !important;}\ #speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ .speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; From 841a9b215b0efef893fc3768330ee6f8c66cc829 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 12 Jan 2022 19:45:21 +0800 Subject: [PATCH 0474/1027] fixed reaction --- NyaaTorrentHelper.user.js | 110 ++++++++++++++------------------------ 1 file changed, 41 insertions(+), 69 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 3905b89..60809d6 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 5.3 +// @version 5.4 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -46,7 +46,7 @@ if (['502 Bad Gateway', '429 Too Many Requests'].includes(document.title)) { var css= document.createElement('style'); css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin-top: 8px;}\ #filter-menu button {background-color: #056b00; margin-top: -3px;}\ -#filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; display: none; overflow-x: hidden; z-index: 9999999;}\ +#filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; display: none; overflow-x: hidden; z-index: 3213;}\ #filter-list > * {display: grid; grid-template-columns: 700px 70px 70px 70px 70px; position: relative;}\ #filter-list > * > * {padding: 10px 5px; margin: 1px; color: #fff; border-radius: 5px; text-decoration: none;}\ #filter-list > * > *:not(:first-child, text) {text-align: center; cursor: pointer; user-select: none;}\ @@ -56,12 +56,12 @@ css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin #filter-list > * > *:nth-child(3):not(text) {background-color: #0056b0;}\ #filter-list > * > *:nth-child(4) {background-color: #056b00;}\ #filter-list > * > *:nth-child(5) {background-color: #0005cc;}\ -#filter-preview {position: absolute; z-index: 3213;}'; +#filter-preview {position: absolute; z-index: 3213; max-height: 800px; width: auto;}'; document.head.appendChild(css); var menu = document.createElement('div'); menu.id = 'filter-menu'; -menu.innerHTML = ''; +menu.innerHTML = ''; document.querySelector('#navbar').appendChild(menu); menu.querySelector('input').addEventListener('keypress', event => event.key === 'Enter' && menu.querySelector('button').click()); menu.querySelector('button').addEventListener('click', event => { @@ -92,14 +92,15 @@ function getFilterResult(data) { '' + i18n.magnet + '\ ' + i18n.copy + ''; popup.appendChild(menu); - menu.querySelector('#preview').addEventListener('click', event => { + menu.querySelector('#preview').addEventListener('click', async event => { + await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); event.target.style.cssText = 'background-color: #C3C;'; - getPreviewHandler(data, {top: event.clientY, left: event.clientX}); }); - menu.querySelector('#copy').addEventListener('click', event => { + menu.querySelector('#copy').addEventListener('click', async event => { event.target.innerText = '!'; - navigator.clipboard.writeText(i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.image ? data.image : data.web ? data.web : '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet); - setTimeout(() => {event.target.innerText = i18n.copy;}, 1000); + var url = !data.type && await xmlNodeHandler(data.src).then(({url}) => url) ; + navigator.clipboard.writeText(i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.type ? data.url : url ?? '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet); + event.target.innerText = i18n.copy; }); } @@ -112,92 +113,63 @@ document.querySelectorAll('table > tbody > tr').forEach((element) => { var src = a.href; var size = element.querySelector('td:nth-child(4)').innerText; var link = element.querySelectorAll('td:nth-child(3) > a'); - if (link.length === 2) { - var torrent = link[0].href; - var magnet = slimMagnetURI(link[1].href); - } - else { - magnet = slimMagnetURI(link[0].href); - } + var torrent = link.length === 2 ? link[0].href : null; + var magnet = link.length === 2 ? link[1].href : link[0].href; + magnet = magnet.slice(0, magnet.indexOf('&')); var data = {id, name, src, size, torrent, magnet}; queue.push(data); - a.addEventListener('contextmenu', event => { + a.addEventListener('contextmenu', async event => { event.preventDefault(); + await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); a.style.cssText = 'color: #C33;'; - getPreviewHandler(data, {top: event.clientY, left: event.clientX}); }); }); -function slimMagnetURI(magnet) { - return magnet.slice(0, magnet.indexOf('&')); -} - // Preview handler -function getPreviewHandler(data, mouse) { +async function getPreviewHandler(data, mouse) { if (action[data.id] || document.getElementById('preview-' + data.id)) { return; } action[data.id] = true; - if (data.none) { - noValidPreview(data); - } - else if (data.image) { - createPreview(data, mouse); - } - else if (data.new) { - openWebPreview(data); - } - else { - xmlNodeHandler(data, mouse, getPreviewURL); - } + data.type === 'none' ? alert(data.name + '\nNo Preview!') : + data.type === 'image' ? createPreview(data.url, mouse) : + data.type === 'host' ? GM_openInTab(data.url, true) : await xmlNodeHandler(data.src).then(({type, url}) => { + data.type = type; + data.url = url; + action[data.id] = false; + getPreviewHandler(data, mouse); + }).catch(error => { action[data.id] = getPreviewHandler(data, mouse); }); + action[data.id] = false; } -function xmlNodeHandler(data, mouse, handler) { - fetch(data.src).then(response => response.text()).then(text => { +function xmlNodeHandler(url) { + return fetch(url).then(response => response.text()).then(text => { if (text.includes('502 Bad Gateway')) { throw new Error('502 Bad Gateway'); } else { var node = document.createElement('div'); node.innerHTML = text; - handler(node, data, mouse); + var desc = node.querySelector('#torrent-description').innerText; + var img = /https?:\/\/[^\)\]]+\.(jpg|png)/g.exec(desc); + if (img) { + return {type: 'image', url: img[0]}; + } + var url = /https?:\/\/[^\*\r\n\)\]]+/g.exec(desc); + if (url) { + return {type: 'host', url: url[0]}; + } + return {type: 'none'}; } - }).catch(error => setTimeout(() => xmlNodeHandler(data, mouse, handler), 5000)); -} - -function getPreviewURL(node, data, mouse) { - var description = node.querySelector('#torrent-description').innerHTML; - var img = /https?:\/\/[^\)\]]+\.(jpg|png)/g.exec(description); - if (img) { - data.image = img[0]; - return createPreview(data, mouse); - } - var url = /https?:\/\/[^\*\r\n\)\]]+/g.exec(description); - if (url) { - data.web = url[0]; - return openWebPreview(data); - } - data.none = true; - noValidPreview(data); -} - -function openWebPreview(data) { - GM_openInTab(data.web, true); - action[data.id] = false; -} - -function noValidPreview(data) { - alert(data.name + '\nNo Preview!'); - action[data.id] = false; + }); } // Create preview -function createPreview(data, mouse) { +function createPreview(url, mouse) { var image = document.createElement('img'); image.id = 'filter-preview'; - image.src = data.image; - image.style.cssText = 'max-height: 800px; width: auto; top: ' + (mouse.top + 800 > innerHeight ? innerHeight - 800 : mouse.top) + 'px; left: ' + (mouse.left + 600 > innerWidth ? innerWidth - 600 : mouse.left) + 'px;'; + image.src = url; + image.style.cssText = 'top: ' + (mouse.top + 800 > innerHeight ? innerHeight - 800 : mouse.top) + 'px; left: ' + (mouse.left + 600 > innerWidth ? innerWidth - 600 : mouse.left) + 'px;'; image.addEventListener('click', event => image.remove()); document.body.appendChild(image); - action[data.id] = false; } From ed5a441a16911c97b808ee4a0bbbfa93e903caee Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 12 Jan 2022 20:39:02 +0800 Subject: [PATCH 0475/1027] clean up --- NyaaTorrentHelper.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 60809d6..aa11a27 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -98,8 +98,8 @@ function getFilterResult(data) { }); menu.querySelector('#copy').addEventListener('click', async event => { event.target.innerText = '!'; - var url = !data.type && await xmlNodeHandler(data.src).then(({url}) => url) ; - navigator.clipboard.writeText(i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.type ? data.url : url ?? '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet); + data = {...data, ...(!data.type && await xmlNodeHandler(data.src))}; + navigator.clipboard.writeText(i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.url ?? '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet); event.target.innerText = i18n.copy; }); } From 551276ac2d42b419e7f1e3f7278e1df7ec2c9845 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 13 Jan 2022 09:07:55 +0800 Subject: [PATCH 0476/1027] fixed maximum --- SpeedRunHelper.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 1553cc3..b8975de 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.0 +// @version 3.1 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -28,7 +28,7 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-item:active {filter: opacity(30%);}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 25% !important; height: 20px !important; z-index: 99999;}\ .speedrun-minimum iframe {display: none !important;}\ -.speedrun-maximum {top: 0px; left: 0px; width: ' + (outerWidth - 54) + 'px !important; height: ' + (outerHeight - 60) + 'px !important; z-index: 999999;}\ +.speedrun-maximum {top: 0px; left: 0px; width: ' + document.documentElement.offsetWidth + 'px !important; height: ' + (document.documentElement.offsetHeight - 304) + 'px !important; z-index: 999999;}\ .speedrun-maximum iframe {width: 100% !important; height: calc(100% - 20px) !important;}\ #speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ .speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; From 153699c23afbf023af17116f64a8085231becd8f Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 13 Jan 2022 18:18:05 +0800 Subject: [PATCH 0477/1027] Update SpeedRunHelper.user.js --- SpeedRunHelper.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index b8975de..89aa0ff 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -28,7 +28,7 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-item:active {filter: opacity(30%);}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 25% !important; height: 20px !important; z-index: 99999;}\ .speedrun-minimum iframe {display: none !important;}\ -.speedrun-maximum {top: 0px; left: 0px; width: ' + document.documentElement.offsetWidth + 'px !important; height: ' + (document.documentElement.offsetHeight - 304) + 'px !important; z-index: 999999;}\ +.speedrun-maximum {top: 0px; left: 0px; width: ' + (screen.availWidth - 52) + 'px !important; height: ' + (screen.availHeight - 64) + 'px !important; z-index: 999999;}\ .speedrun-maximum iframe {width: 100% !important; height: calc(100% - 20px) !important;}\ #speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ .speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; From 32897d92c4a7bb0984acff197d852781a89b0313 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 13 Jan 2022 19:03:50 +0800 Subject: [PATCH 0478/1027] minor update --- SpeedRunHelper.user.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 89aa0ff..af90b79 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -23,15 +23,16 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-top {position: relative; background-color: #52698A; width: 100%; user-select: none; height: 20px;}\ .speedrun-title > * {display: inline-block; width: 25%;}\ .speedrun-menu {position: absolute; right: 0px; top: 0px;}\ -.speedrun-item {background-color: #fff; cursor: pointer; display: inline-block; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 2px;}\ +.speedrun-item {background-color: #fff; color: #000; cursor: pointer; display: inline-block; height: 20px; width: 20px; font-size: 14px; text-align: center; vertical-align: top; margin-left: 2px;}\ .speedrun-item:hover {filter: opacity(60%);}\ .speedrun-item:active {filter: opacity(30%);}\ +#speedrun-minimum {line-height: 30px;}\ .speedrun-minimum {bottom: 0px; left: 0px; width: 25% !important; height: 20px !important; z-index: 99999;}\ .speedrun-minimum iframe {display: none !important;}\ .speedrun-maximum {top: 0px; left: 0px; width: ' + (screen.availWidth - 52) + 'px !important; height: ' + (screen.availHeight - 64) + 'px !important; z-index: 999999;}\ .speedrun-maximum iframe {width: 100% !important; height: calc(100% - 20px) !important;}\ #speedrun-restore, .speedrun-minimum #speedrun-minimum, .speedrun-maximum #speedrun-maximum {display: none;}\ -.speedrun-minimum #speedrun-restore, .speedrun-maximum #speedrun-restore {display: inline-block;}'; +.speedrun-minimum #speedrun-restore:nth-child(2), .speedrun-maximum #speedrun-restore:nth-child(4) {display: inline-block;}'; document.body.append(css); document.getElementById('leaderboarddiv').addEventListener('contextmenu', event => { @@ -80,9 +81,10 @@ function createRecordWindow(id, title, content) { container.draggable = 'true'; container.className = 'speedrun-window'; container.innerHTML = '
' + title + '
\ -
📌\ +
\ +🔳\ 🔲\ -\ +🔳\
'; style[id] = container.style.cssText = 'top: ' + (130 + container.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + container.idx * 30) + 'px;'; document.body.appendChild(container); @@ -97,10 +99,10 @@ function createRecordWindow(id, title, content) { container.classList.remove('speedrun-minimum'); container.style.cssText = ''; }); - container.querySelector('#speedrun-restore').addEventListener('click', event => { + container.querySelectorAll('#speedrun-restore').forEach(button => button.addEventListener('click', event => { container.classList.remove('speedrun-maximum', 'speedrun-minimum'); container.style.cssText = style[id]; - }); + })); container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); }); From 935992960525b379625b21365842b399ed092299 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 13 Jan 2022 23:42:33 +0800 Subject: [PATCH 0479/1027] Create filereader.js --- libs/filereader.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libs/filereader.js diff --git a/libs/filereader.js b/libs/filereader.js new file mode 100644 index 0000000..bb6e550 --- /dev/null +++ b/libs/filereader.js @@ -0,0 +1,20 @@ +(function() { + this.promiseFileReader = i => { + var f = new FileReader(); + return new Promise((r, r) => { + r({ + text: () => s('readAsText'), + arrayBuffer: () => s('readAsArrayBuffer'), + binary: () => s('readAsBinaryString'), + dataURL: () => s('readAsDataURL') + }); + }); + function s(type) { + return new Promise((r, e) => { + f.onload = () => r(f.result); + f.onerror = e; + f[type](i); + }); + } + }; +})(); From 21c61f23f12e472d2f2e1e38f2d60b6134b2b295 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 13 Jan 2022 23:44:01 +0800 Subject: [PATCH 0480/1027] Update filereader.js --- libs/filereader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/filereader.js b/libs/filereader.js index bb6e550..6ba160d 100644 --- a/libs/filereader.js +++ b/libs/filereader.js @@ -1,7 +1,7 @@ (function() { this.promiseFileReader = i => { var f = new FileReader(); - return new Promise((r, r) => { + return new Promise((r, e) => { r({ text: () => s('readAsText'), arrayBuffer: () => s('readAsArrayBuffer'), From 6b858c14ed0dca53888ec306d493562ff3c1a821 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:02:57 +0800 Subject: [PATCH 0481/1027] update ad remove --- RawMangaAssistant.user.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 12cf5cb..f3f6e71 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.9 +// @version 6.10 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -46,10 +46,9 @@ // @webRequest {"selector": "*.exosrv.com/*", "action": "cancel"} // @webRequest {"selector": "*.bidgear.com/*", "action": "cancel"} // klmag.net -// @webRequest {"selector": "*.adtcdn.com/*", "action": "cancel"} -// @webRequest {"selector": "*.greeter.me/*", "action": "cancel"} -// @webRequest {"selector": "*.modoro360.com/*", "action": "cancel"} -// weloma.art / weloma.net +// @webRequest {"selector": "*.wpadmngr.com/*", "action": "cancel"} +// @webRequest {"selector": "*cynicaugural.com/*", "action": "cancel"} +// weloma.art / weloma.net / klmag.net // @webRequest {"selector": "*.pubfuture.com/*", "action": "cancel"} // ==/UserScript== From a3aef28f7709e2fee77946aeafbfb4c046bf7115 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:17:18 +0800 Subject: [PATCH 0482/1027] Update aria2request.js --- libs/aria2request.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index b12b00d..2832816 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -2,17 +2,16 @@ this.aria2 = { jsonrpc: null, secret: null, - send: (m, p) => s({id: '', jsonrpc: 2, method: m, params: ['token:' + aria2.secret].concat(p ?? [])}), - multi: (p) => s({id: '', jsonrpc: 2, method: 'system.multicall', params: [p.map(m)]}) + send: (r) => s('method' in r ? {id: '', jsonrpc: 2, method: r.method, params: ['token:' + aria2.secret].concat(r.params ?? [])} : m(r)); }; - + function s(j) { return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) - .then(r => { if (r.ok) { return r.json(); } else { throw new Error(r.statusText); } }) - .then(j => { if ('result' in j) { return j.result; } else { throw j.error; } }); + .then(r => { if (r.status !== 200) { throw new Error(r.statusText); } return r.json(); }) + .then(j => { if (j.resolve[0] && j.result[0].constructor === Object) { throw j.error; } return j.result; }); } - function m({method, params}) { - return {methodName: method, params: ['token:' + aria2.secret].concat(params ?? [])}; + function m(p) { + return {id: '', jsonrpc: 2, method: 'system.multicall', params: [p.map(({method, params} => ({methodName: method, params: ['token:' + aria2.secret].concat(params ?? [])})))]} } })(); From d70a3fb6f8aee89d5455b98ebb542575b4e2b6cf Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:19:34 +0800 Subject: [PATCH 0483/1027] oops --- libs/aria2request.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 2832816..4a21e51 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -2,7 +2,7 @@ this.aria2 = { jsonrpc: null, secret: null, - send: (r) => s('method' in r ? {id: '', jsonrpc: 2, method: r.method, params: ['token:' + aria2.secret].concat(r.params ?? [])} : m(r)); + send: (r) => s('method' in r ? {id: '', jsonrpc: 2, method: r.method, params: ['token:' + aria2.secret].concat(r.params ?? [])} : {id: '', jsonrpc: 2, method: 'system.multicall', params: [r.map(({method, params}) => ({methodName: method, params: ['token:' + aria2.secret].concat(params ?? [])}))]}) }; function s(j) { @@ -10,8 +10,4 @@ .then(r => { if (r.status !== 200) { throw new Error(r.statusText); } return r.json(); }) .then(j => { if (j.resolve[0] && j.result[0].constructor === Object) { throw j.error; } return j.result; }); } - - function m(p) { - return {id: '', jsonrpc: 2, method: 'system.multicall', params: [p.map(({method, params} => ({methodName: method, params: ['token:' + aria2.secret].concat(params ?? [])})))]} - } })(); From 3e5969bed9bf8ab334e75a7c4551bc0ce1b569f7 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:31:35 +0800 Subject: [PATCH 0484/1027] typo --- libs/aria2request.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 4a21e51..23b720d 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -2,12 +2,12 @@ this.aria2 = { jsonrpc: null, secret: null, - send: (r) => s('method' in r ? {id: '', jsonrpc: 2, method: r.method, params: ['token:' + aria2.secret].concat(r.params ?? [])} : {id: '', jsonrpc: 2, method: 'system.multicall', params: [r.map(({method, params}) => ({methodName: method, params: ['token:' + aria2.secret].concat(params ?? [])}))]}) + send: (r) => s('method' in r ? {id: '', jsonrpc: 2, method: r.method, params: ['token:' + aria2.secret].concat(r.params ?? [])} : {id: '', jsonrpc: 2, method: 'system.multicall', params: [r.map(({method, params = []}) => ({methodName: method, params: ['token:' + aria2.secret, ...params]}))]}) }; function s(j) { return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) .then(r => { if (r.status !== 200) { throw new Error(r.statusText); } return r.json(); }) - .then(j => { if (j.resolve[0] && j.result[0].constructor === Object) { throw j.error; } return j.result; }); + .then(j => { if (j.result[0] && j.result[0].constructor === Object) { throw j.error; } return j.result; }); } })(); From ee71f6fb8689866bd50a9203e8c2b4ae7a475f45 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:34:15 +0800 Subject: [PATCH 0485/1027] update aria2request.js --- RawMangaAssistant.user.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index f3f6e71..f3f80f9 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @namespace https://github.com/jc3213/userscript // @name:zh 漫画生肉网站助手 -// @version 6.10 +// @version 6.11 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -16,7 +16,7 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-TgEDPu1UA9s6kvQGehhlf8pwW3rxvWg+/BF7P1qB0/4= // @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= // @grant GM_getValue // @grant GM_setValue @@ -271,16 +271,15 @@ container.querySelector('#aria2download').addEventListener('click', event => { var json; var folder; var request = () => { - aria2.send('aria2.getGlobalOption').then(result => { - folder = folder ?? result.dir + extractMangaTitle(); + aria2.send({method: 'aria2.getGlobalOption'}).then(({dir}) => { + folder = folder ?? dir + extractMangaTitle(); json = json ?? urls.map((url, index) => ({method: 'aria2.addUri', params: [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}]})); - aria2.multi(json).then(result => notification('aria2', 'done')); + aria2.send(json).then(result => notification('aria2', 'done')); }).catch(error => { alert(i18n.aria2.error); aria2.jsonrpc = prompt('Aria2 JSONRPC URI', aria2.jsonrpc) ?? aria2.jsonrpc; aria2.secret = prompt('Aria2 Secret Token', aria2.secret) ?? aria2.secret; GM_setValue('aria2', aria2); - request(); }); } request(); From bd88bf86360dd33d2b3c761afa4446007fec1f91 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:35:48 +0800 Subject: [PATCH 0486/1027] oops fixed error --- libs/aria2request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 23b720d..52a695f 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -8,6 +8,6 @@ function s(j) { return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) .then(r => { if (r.status !== 200) { throw new Error(r.statusText); } return r.json(); }) - .then(j => { if (j.result[0] && j.result[0].constructor === Object) { throw j.error; } return j.result; }); + .then(j => { if (j.result[0] && j.result[0].constructor === Object) { throw j.result[0]; } return j.result; }); } })(); From 962959cdfb3b07a57da2b2b48a7d4796e06a36fe Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:41:06 +0800 Subject: [PATCH 0487/1027] minor update --- libs/aria2request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/aria2request.js b/libs/aria2request.js index 52a695f..7f116bb 100644 --- a/libs/aria2request.js +++ b/libs/aria2request.js @@ -8,6 +8,6 @@ function s(j) { return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) .then(r => { if (r.status !== 200) { throw new Error(r.statusText); } return r.json(); }) - .then(j => { if (j.result[0] && j.result[0].constructor === Object) { throw j.result[0]; } return j.result; }); + .then(j => { var r = j.result; if (r[0] && r[0].constructor === Object) { throw r[0]; } return r; }); } })(); From f681e1ccecc8742b9eb73b27393506a78d42d68a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 14:41:59 +0800 Subject: [PATCH 0488/1027] Update RawMangaAssistant.user.js --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index f3f80f9..14698e1 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,7 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-TgEDPu1UA9s6kvQGehhlf8pwW3rxvWg+/BF7P1qB0/4= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-m8uu3xenbReyQ3OmOyoX5Nfsu/r5B4Vg4N2akZgd8Tk= // @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= // @grant GM_getValue // @grant GM_setValue From 732f2f11d526fb22541a4bb37416ee1f11c25a2e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 21 Jan 2022 23:02:12 +0800 Subject: [PATCH 0489/1027] improved performance --- RawMangaAssistant.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 14698e1..83bdd65 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -181,10 +181,10 @@ manga['manga1001.com'] = manga['manga1000.com']; manga['weloma.net'] = manga['weloma.art']; watching = manga[location.host]; -function longDecimalNumber(number, length = 3) { - number = number.toString(); - var float = number.length - number.split(/[\._-]/)[0].length; - return (10 ** length + number).slice(0 - length - float); +function longDecimalNumber(input, length = 3) { + var number = isNaN(input) ? input : input.toString(); + var float = number.indexOf('.'); + return (10 ** length + number).slice(0 - length - (float === -1 ? 0 : number.length - float)); } function extractMangaTitle(title = '') { From 1acc74fbd91838448334af64f0e52aee91cb3d0e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 4 Feb 2022 15:22:29 +0800 Subject: [PATCH 0490/1027] fix ui for new bilibili style --- BilibiliVideoDownloader.user.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index a0f30f6..802ca54 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 2.18 +// @version 2.19 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -39,7 +39,7 @@ menu.append(thumb, video, audio); var css = document.createElement('style'); css.innerHTML = '#download-box > * {position: relative; display: inline-block; margin: -5px 1px 5px; height: 38px; overflow-y: hidden; vertical-align: top;}\ #download-box > *:hover {height: max-content; z-index: 999999;}\ -#download-box a {background-color: #c26; color: #fff; display: block; margin-top: 1px; height: 16px; line-height: 16px; padding: 10px; text-align: center;}\ +#download-box a {background-color: #c26; color: #fff; display: block; margin-top: 1px; font-size: 16px; height: 16px; line-height: 16px; padding: 10px; text-align: center;}\ #download-box a:hover {background-color: #26c;}'; setTimeout(() => { @@ -47,16 +47,18 @@ setTimeout(() => { var toolbar = document.querySelector('#arc_toolbar_report') ?? document.querySelector('#toolbar_module'); player.addEventListener('progress', () => { if (title === '') { - if (location.pathname.startsWith('/video/')) { - bilibiliVideoTitle(__INITIAL_STATE__.videoData.title); - biliVideoThumbnail(__INITIAL_STATE__.elecFullInfo.data.pic); - biliVideoExtractor('x/player/playurl?avid=' + __INITIAL_STATE__.aid + '&cid=' + __INITIAL_STATE__.cidMap[__INITIAL_STATE__.aid].cids[__INITIAL_STATE__.p], 'data'); + var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; + if (aid && cid) { + biliVideoTitle(videoData.title); + biliVideoThumbnail(elecFullInfo.data.pic); + biliVideoExtractor('x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'); biliVideoAutoWide('div.bilibili-player-video-btn-widescreen', 'closed'); + menu.style.cssText = 'position: relative; top: 5px;'; } else { - bilibiliVideoTitle(__INITIAL_STATE__.h1Title); - biliVideoThumbnail(__INITIAL_STATE__.epInfo.cover); - biliVideoExtractor('pgc/player/web/playurl?ep_id=' + __INITIAL_STATE__.epInfo.id, 'result'); + biliVideoTitle(h1Title); + biliVideoThumbnail(epInfo.cover); + biliVideoExtractor('pgc/player/web/playurl?ep_id=' + epInfo.id, 'result'); biliVideoAutoWide('div.squirtle-video-widescreen', 'active'); } } @@ -67,7 +69,7 @@ setTimeout(() => { toolbar.append(menu, css); }, 1500); -function bilibiliVideoTitle(name) { +function biliVideoTitle(name) { var multi = document.querySelector('#multi_page li.on > a'); title = (name + (multi ? multi.innerText : '')).replace(/[\/\\\?\|\<\>:"']/g, ''); } From 70e19dbfb7646b4a6815a4843a6476eac82a6815 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 21:08:42 +0800 Subject: [PATCH 0491/1027] use class and promise support for websocket --- libs/aria2js | 31 +++++++++++++++++++++++++++++++ libs/aria2request.js | 13 ------------- 2 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 libs/aria2js delete mode 100644 libs/aria2request.js diff --git a/libs/aria2js b/libs/aria2js new file mode 100644 index 0000000..da4a55b --- /dev/null +++ b/libs/aria2js @@ -0,0 +1,31 @@ +class Aria2 { + constructor(jsonrpc, secret) { + this.jsonrpc = jsonrpc; + this.secret = 'token:' + secret; + this.sender = jsonrpc.startsWith('http') ? this.http : this.socket; + } + http (body) { + return new Promise((resolve, reject) => { + fetch(this.jsonrpc, {method: 'POST', body}) + .then(response => response.json()) + .then(({result, error}) => result ? resolve(result) : reject()) + .catch(reject); + }); + } + socket (message) { + return new Promise((resolve, reject) => { + var socket = new WebSocket(this.jsonrpc); + socket.onopen = event => socket.send(message); + socket.onclose = reject; + socket.onmessage = event => { + var {result, error} = JSON.parse(event.data); + result ? resolve(result) : reject(); + socket.close(); + }; + }); + } + message (method, params = []) { + var message = JSON.stringify({id: '', jsonrpc: 2, method, params: [this.secret, ...params]}); + return this.sender(message); + } +} diff --git a/libs/aria2request.js b/libs/aria2request.js deleted file mode 100644 index 7f116bb..0000000 --- a/libs/aria2request.js +++ /dev/null @@ -1,13 +0,0 @@ -(function () { - this.aria2 = { - jsonrpc: null, - secret: null, - send: (r) => s('method' in r ? {id: '', jsonrpc: 2, method: r.method, params: ['token:' + aria2.secret].concat(r.params ?? [])} : {id: '', jsonrpc: 2, method: 'system.multicall', params: [r.map(({method, params = []}) => ({methodName: method, params: ['token:' + aria2.secret, ...params]}))]}) - }; - - function s(j) { - return fetch(aria2.jsonrpc, {method: 'POST', body: JSON.stringify(j)}) - .then(r => { if (r.status !== 200) { throw new Error(r.statusText); } return r.json(); }) - .then(j => { var r = j.result; if (r[0] && r[0].constructor === Object) { throw r[0]; } return r; }); - } -})(); From 36c4c660fb78264c41e941b9520641fb7defc237 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 21:10:24 +0800 Subject: [PATCH 0492/1027] set as class, promise method, support websocket --- libs/{aria2js => aria2.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libs/{aria2js => aria2.js} (100%) diff --git a/libs/aria2js b/libs/aria2.js similarity index 100% rename from libs/aria2js rename to libs/aria2.js From 4d2400847d2db4a8994d602fc2a7f04b9ffab776 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 21:13:54 +0800 Subject: [PATCH 0493/1027] Update aria2request.md --- libs/aria2request.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libs/aria2request.md b/libs/aria2request.md index 60f5d09..47468c7 100644 --- a/libs/aria2request.md +++ b/libs/aria2request.md @@ -1,24 +1,19 @@ ## How to implement ### HTML ```HTML - + ``` ### TamperMonkey ```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2request.js#sha256-wzomqXdCxnFpRTaVKPS+BWGKaScbF+PhAjX+EMxOLBo= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2.js#sha256-x9Xlp9IO/8Qu6vkkaE5DZXUZK/Mz4RD2yAGiVRtYqQQ= ``` ## Syntax ```javascript -const aria2.jsonrpc = 'http://localhost:6800/jsonrpc'; -const aria2.secret = 'Your secret token'; -const result = aria2.send(method, params); -const arrayResult = aria2.multi([ {method0, params0}, {method1, params1} ]); +const aria2 = new Aria2(jsonrpc, secret);; +const result = aria2.message(method, params); ``` ### `method` `*required`, `params` `Optional` Read [RPC method calls](https://aria2.github.io/manual/en/html/aria2c.html#methods) ### `result` -Promise object, returns an `object` if fufilled -### `arrayResult` -Promise object, returns an `array` if fufilled\ -`[ [result0], [result1], ... ]` +Promise object, returns an `object` if fulfilled From 5a0a6e59c1955710a1ee07312cb57df300f9511e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 21:14:09 +0800 Subject: [PATCH 0494/1027] Rename aria2request.md to aria2.md --- libs/{aria2request.md => aria2.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libs/{aria2request.md => aria2.md} (100%) diff --git a/libs/aria2request.md b/libs/aria2.md similarity index 100% rename from libs/aria2request.md rename to libs/aria2.md From 1e96540f2512bc3689543d04a27fc3317e96efb7 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 21:22:43 +0800 Subject: [PATCH 0495/1027] Update aria2.md --- libs/aria2.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/aria2.md b/libs/aria2.md index 47468c7..800ea8b 100644 --- a/libs/aria2.md +++ b/libs/aria2.md @@ -1,4 +1,4 @@ -## How to implement +## How to Use ### HTML ```HTML +``` +### TamperMonkey +```javascript +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/filereader.js#sha256-ra0CJCuvv/O10tgFcdiSFYFQXxEIa+KYMXHx1lsx7VE= +``` +## Syntax +```javascript +const reader = PromiseFileReader(file); +``` +### `file` +A javascript File object +```javascript +const text = reader.text(); +``` +### `text` +Promise object, returns the contents of the file as a text `string` if fulfilled +```javascript +const data = reader.data(); +``` +### `data` +Promise object, returns a `data:` URL representing the file's data if fulfilled +```javascript +const buffer = reader.buffer(); +``` +### `buffer` +Promise object, returns an `ArrayBuffer` representing the file's data if fulfilled +```javascript +const binary = reader.binary(); +``` +### `binary` +Promise object, returns the raw binary data from the file as a `string` if fulfilled From 58aaa699a2880c3ea3b08632eca9f3a7f3d2e5bb Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:05:20 +0800 Subject: [PATCH 0499/1027] Update filereader.md --- libs/filereader.md | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/libs/filereader.md b/libs/filereader.md index 057a32c..5b48b06 100644 --- a/libs/filereader.md +++ b/libs/filereader.md @@ -14,23 +14,12 @@ const reader = PromiseFileReader(file); ``` ### `file` A javascript File object -```javascript -const text = reader.text(); -``` -### `text` -Promise object, returns the contents of the file as a text `string` if fulfilled -```javascript -const data = reader.data(); -``` -### `data` -Promise object, returns a `data:` URL representing the file's data if fulfilled -```javascript -const buffer = reader.buffer(); -``` -### `buffer` -Promise object, returns an `ArrayBuffer` representing the file's data if fulfilled -```javascript -const binary = reader.binary(); -``` -### `binary` -Promise object, returns the raw binary data from the file as a `string` if fulfilled +## Method +### `reader.text()` +Return a promise object, which returns the contents of the file as a text `string` if fulfilled +### `reader.data()` +Return a promise object, which returns a `data:` URL representing the file's data if fulfilled +### `reader.buffer()` +Return a promise object, which returns an `ArrayBuffer` representing the file's data if fulfilled +### `reader.binary()` +Return a promise object, which returns the raw binary data from the file as a `string` if fulfilled From a59568a8e9659f0fcbf019c17b967b072d04e0d8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:06:03 +0800 Subject: [PATCH 0500/1027] Update aria2.md --- libs/aria2.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/aria2.md b/libs/aria2.md index 800ea8b..167082e 100644 --- a/libs/aria2.md +++ b/libs/aria2.md @@ -16,6 +16,7 @@ const aria2 = new Aria2(jsonrpc, secret); Address of aria2 JSON-RPC ### `secret` `Optional` Secret token of aria2 JSON-RPC +## Method ```javascript const result = aria2.message(method, params); ``` From 0934ff109d525020110197f8e9c633c99529403b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:06:40 +0800 Subject: [PATCH 0501/1027] Update filereader.js --- libs/filereader.js | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/filereader.js b/libs/filereader.js index 9b8f5a9..299c170 100644 --- a/libs/filereader.js +++ b/libs/filereader.js @@ -6,6 +6,7 @@ class PromiseFileReader { return new Promise((resolve, reject) => { var reader = new FileReader(); reader.onload = event => resolve(reader.result); + reader.onerror = reject; reader[method](this.file); }); } From 0fe1a1f7b7d200eb890de4b7a1b67250e02aef60 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:07:38 +0800 Subject: [PATCH 0502/1027] Update filereader.md --- libs/filereader.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/filereader.md b/libs/filereader.md index 5b48b06..c964932 100644 --- a/libs/filereader.md +++ b/libs/filereader.md @@ -2,11 +2,11 @@ ### HTML ```HTML + integrity="sha256-84vezI4SRK1h06YWE6Jy3ZZcKrc4P47h1j29btJP0xo=" crossorigin="anonymous"> ``` ### TamperMonkey ```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/filereader.js#sha256-ra0CJCuvv/O10tgFcdiSFYFQXxEIa+KYMXHx1lsx7VE= +// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/filereader.js#sha256-84vezI4SRK1h06YWE6Jy3ZZcKrc4P47h1j29btJP0xo= ``` ## Syntax ```javascript From 122f0332303dba23f1ceffdf65b2277b27463308 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:16:16 +0800 Subject: [PATCH 0503/1027] update aria2.js --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 4ca2ae6..964d606 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,7 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2.js#sha256-x9Xlp9IO/8Qu6vkkaE5DZXUZK/Mz4RD2yAGiVRtYqQQ= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2.js#sha256-x9Xlp9IO/8Qu6vkkaE5DZXUZK/Mz4RD2yAGiVRtYqQQ= // @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= // @grant GM_getValue // @grant GM_setValue From b0b5ed478977f31e580f29c9bee986e90fa59185 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:16:26 +0800 Subject: [PATCH 0504/1027] Delete aria2.js --- libs/aria2.js | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 libs/aria2.js diff --git a/libs/aria2.js b/libs/aria2.js deleted file mode 100644 index da4a55b..0000000 --- a/libs/aria2.js +++ /dev/null @@ -1,31 +0,0 @@ -class Aria2 { - constructor(jsonrpc, secret) { - this.jsonrpc = jsonrpc; - this.secret = 'token:' + secret; - this.sender = jsonrpc.startsWith('http') ? this.http : this.socket; - } - http (body) { - return new Promise((resolve, reject) => { - fetch(this.jsonrpc, {method: 'POST', body}) - .then(response => response.json()) - .then(({result, error}) => result ? resolve(result) : reject()) - .catch(reject); - }); - } - socket (message) { - return new Promise((resolve, reject) => { - var socket = new WebSocket(this.jsonrpc); - socket.onopen = event => socket.send(message); - socket.onclose = reject; - socket.onmessage = event => { - var {result, error} = JSON.parse(event.data); - result ? resolve(result) : reject(); - socket.close(); - }; - }); - } - message (method, params = []) { - var message = JSON.stringify({id: '', jsonrpc: 2, method, params: [this.secret, ...params]}); - return this.sender(message); - } -} From 071b2f4a0e1b8158dd032b137cdac6470bd80027 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:16:32 +0800 Subject: [PATCH 0505/1027] Delete aria2.md --- libs/aria2.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 libs/aria2.md diff --git a/libs/aria2.md b/libs/aria2.md deleted file mode 100644 index 167082e..0000000 --- a/libs/aria2.md +++ /dev/null @@ -1,28 +0,0 @@ -## How to Use -### HTML -```HTML - -``` -### TamperMonkey -```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/aria2.js#sha256-x9Xlp9IO/8Qu6vkkaE5DZXUZK/Mz4RD2yAGiVRtYqQQ= -``` -## Syntax -```javascript -const aria2 = new Aria2(jsonrpc, secret); -``` -### `jsonrpc` `*required` -Address of aria2 JSON-RPC -### `secret` `Optional` -Secret token of aria2 JSON-RPC -## Method -```javascript -const result = aria2.message(method, params); -``` -### `method` `*required` -Read [RPC method calls](https://aria2.github.io/manual/en/html/aria2c.html#methods) -### `params` `Optional` -An array contains RPC method call parameters -### `result` -Promise object, returns an `object` if fulfilled From 9c175c7b986f4e67b134461f26e2ad8a9ffc64c6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:23:26 +0800 Subject: [PATCH 0506/1027] Delete filereader.js --- libs/filereader.js | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 libs/filereader.js diff --git a/libs/filereader.js b/libs/filereader.js deleted file mode 100644 index 299c170..0000000 --- a/libs/filereader.js +++ /dev/null @@ -1,25 +0,0 @@ -class PromiseFileReader { - constructor(file) { - this.file = file; - } - reader(method) { - return new Promise((resolve, reject) => { - var reader = new FileReader(); - reader.onload = event => resolve(reader.result); - reader.onerror = reject; - reader[method](this.file); - }); - } - text () { - return this.reader('readAsText'); - } - data () { - return this.reader('readAsDataURL'); - } - buffer () { - return this.reader('readAsArrayBuffer'); - } - binary () { - return this.reader('readAsBinaryString'); - } -} From 1e9e6c591393a21da695f39cc69c8df380dd0bde Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 14 Feb 2022 22:23:29 +0800 Subject: [PATCH 0507/1027] Delete filereader.md --- libs/filereader.md | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 libs/filereader.md diff --git a/libs/filereader.md b/libs/filereader.md deleted file mode 100644 index c964932..0000000 --- a/libs/filereader.md +++ /dev/null @@ -1,25 +0,0 @@ -## How to implement -### HTML -```HTML - -``` -### TamperMonkey -```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/filereader.js#sha256-84vezI4SRK1h06YWE6Jy3ZZcKrc4P47h1j29btJP0xo= -``` -## Syntax -```javascript -const reader = PromiseFileReader(file); -``` -### `file` -A javascript File object -## Method -### `reader.text()` -Return a promise object, which returns the contents of the file as a text `string` if fulfilled -### `reader.data()` -Return a promise object, which returns a `data:` URL representing the file's data if fulfilled -### `reader.buffer()` -Return a promise object, which returns an `ArrayBuffer` representing the file's data if fulfilled -### `reader.binary()` -Return a promise object, which returns the raw binary data from the file as a `string` if fulfilled From 92ce996d34ccb465359bdb12f856f8f7d618a238 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 16 Feb 2022 21:59:10 +0800 Subject: [PATCH 0508/1027] 3.0 --- tsdmAutoSignAndWork.user.js | 167 ++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 94 deletions(-) diff --git a/tsdmAutoSignAndWork.user.js b/tsdmAutoSignAndWork.user.js index 927c757..9faa8db 100644 --- a/tsdmAutoSignAndWork.user.js +++ b/tsdmAutoSignAndWork.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 天使动漫自动签到打工 // @namespace https://github.com/jc3213/userscript -// @version 2.6 +// @version 3.0 // @description 天使动漫全自动打工签到脚本 — 完全自动无需任何操作,只需静待一分钟左右 // @author jc3213 // @match *://www.tsdm39.net/* @@ -17,35 +17,33 @@ var autoed = GM_getValue('autoed', false); var today = new Date().getFullYear() + new Date().getMonth() + new Date().getDate(); var css = document.createElement('style'); -css.innerHTML = '.my-button {padding: 5px; border: 1px outset #000; text-align: center; vertical-align: middle; display: inline-block; background-color: #FFF; width: 60px; height: 20px; cursor: pointer; font-weight: bold;}\ -.my-button:hover {filter: opacity(60%);}\ -.my-button:active {filter: opacity(30%);}\ -.my-menu {background-color: #fff; position: absolute; top: 15px; left: 100px; z-index: 99999;}' +css.innerHTML = '.my-menu {background-color: #fff; position: fixed; top: 40px; right: 100px; width: 100px; z-index: 99999;}\ +.my-menu button {width: 100px; padding: 5px;}\ +iframe {position: absolute; top: 200px; left: 100px; height: 800px; width: 800px; display: none;}'; + var menu = document.createElement('div'); -menu.innerHTML = '签到\ -打工\ -自动'; +menu.innerHTML = '\ +\ +'; menu.className = 'my-menu'; menu.querySelector('.my-auto').innerHTML = autoed ? '✅' : ''; -if (document.querySelector('strong.vwmy')) { - document.head.appendChild(css); - document.body.appendChild(menu); - if (autoed) { - if (today > signed) { - autoHandler('/plugin.php?id=dsu_paulsign:sign', signHandler); - } - if (Date.now() > worked) { - autoHandler('/plugin.php?id=np_cliworkdz:work', workHandler); - } +document.body.append(menu, css); + +if (autoed) { + if (today > signed) { + autoSign(); + } + if (Date.now() > worked) { + autoWork(); } } menu.querySelector('.my-button:nth-child(1)').addEventListener('click', event => { - autoHandler('/plugin.php?id=dsu_paulsign:sign', signHandler); + autoSign(); }); menu.querySelector('.my-button:nth-child(2)').addEventListener('click', event => { - autoHandler('/plugin.php?id=np_cliworkdz:work', workHandler); + autoWork(); }); menu.querySelector('.my-button:nth-child(3)').addEventListener('click', event => { autoed = !autoed; @@ -53,97 +51,78 @@ menu.querySelector('.my-button:nth-child(3)').addEventListener('click', event => GM_setValue('autoed', autoed); }); -function autoHandler(url, load) { - var id = 'auto-' + url.match(/\w{4}$/)[0]; - if (document.getElementById(id)) { - return; - } - var warn = warnStart(id); - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.onload = () => { - var node = document.createElement('div'); - node.innerHTML = xhr.response; - load(node, url, id, warn); - }; - xhr.send() -} - -function signHandler(node, url, id, warn) { - if (node.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)')) { +async function autoSign() { + var warn = await notification('sign'); + var frame = await promiseIframe('/plugin.php?id=dsu_paulsign:sign'); + if (frame.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)')) { GM_setValue('signed', today); - warnOver(id, node.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)').innerHTML); + warn.innerText = frame.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)').innerHTML; + autoEnd(frame, warn); } else { - warn.innerHTML = '开始签到...'; - makeFrame(url, id, autoSign); + warn.innerText = '开始签到...'; + frame.defaultView.Icon_selected('kx'); + document.getElementById('todaysay').value = '每日签到'; + setTimeout(() => { + frame.defaultView.showWindow('qwindow', 'qiandao', 'post', '0'); + GM_setValue('signed', today); + warn.innerText = '已完成签到'; + autoEnd(frame, warn); + }, 3000); } } -function workHandler(node, url, id, warn) { - if (node.querySelector('#messagetext')) { - var text = node.querySelector('#messagetext > p:nth-child(1)').innerHTML.split(/
| -``` -### TamperMonkey -```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-sJFxO/Xi8lu3msbA2J9h46fvpHdacjfmKZ1xJ8AauDM= -``` -## Syntax -```javascript -const meta4 = toMetalink4(input); -``` -### `input` -An array of object `[ object0, object1, ... ]` -#### `object` -An object contains key `{url, name, size, version, locale, hash, metaurl }` -#### url `*required` -The download address of the file\ -Array `[ url0, url1... ]` to generate `https://sam.pl/e.zip`\ -Array `[ [ locale0, url0 ], [ locale1, url1 ]... ]` to generate `https://sam.pl/e.zip` -#### name `Optional` -The name of the file `` -#### size `Optional` -The size of the file `4279183` -#### version `Optional` -The version of the file `1.0.1` -#### locale `Optional` -The language of the file `en` -#### hash `Optional` -The hash of the file\ -Array `[ [ type0, hash0 ], [ type1, hash1 ]... ]` to generate `40a51...1e1d7` -#### metaurl `Optional` -The metaurl address of the file\ -Array `[ [ type0, metaurl0 ], [ type1, metaurl1 ]... ]` to generate `https://sam.pl/e.zip.torrent` -### `meta4` -An object contains the result `{ binary, blob, text, saveAs }` -#### binary -An `array` of text of the result -#### blob -A `blob` object of the result -#### text -A `string` of the result -#### saveAs(filename) `function` -Save the result into a local file. If **filename** is not defined, default filename is `metalink` From 24c20b5b9173889de75c53e5bd7534bbb649f0ef Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 5 Mar 2022 14:33:33 +0800 Subject: [PATCH 0518/1027] update aria2 options --- RawMangaAssistant.user.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index d7317b3..39567d4 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.12 +// @version 6.13 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -16,7 +16,7 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2.js#sha256-x9Xlp9IO/8Qu6vkkaE5DZXUZK/Mz4RD2yAGiVRtYqQQ= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2.js#sha256-/NyeHAvLqSqeD6YbfeQacGIUFZ9FPn46kWmPNmlEInU= // @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= // @grant GM_getValue // @grant GM_setValue @@ -66,8 +66,7 @@ var folder; var options = GM_getValue('options', {menu: 'on', top: 300, left: 150}); var offset; var warning; -var headers = {'Cookie': document.cookie, 'Referer': location.href, 'User-Agent': navigator.userAgent}; -var aria2Headers = ['Cookie: ' + document.cookie, 'Referer: ' + location.href, 'User-Agent:' + navigator.userAgent]; +var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; // i18n strings and labels var message = { @@ -243,10 +242,7 @@ dragndrop({node: button}, (top, left) => { container.querySelector('#download').addEventListener('click', event => { urls.forEach((url, index) => { GM_xmlhttpRequest({ - method: 'GET', - url: url, - responseType: 'blob', - headers: headers, + url, headers, method: 'GET', responseType: 'blob', onload: (details) => { var blob = details.response; var a = document.createElement('a'); @@ -271,14 +267,14 @@ container.querySelector('#scrolltop').addEventListener('click', event => { // Aria2 Menuitems container.querySelector('#aria2download').addEventListener('click', async event => { folder = folder ?? await aria2.message('aria2.getGlobalOption').then(({dir}) => dir + extractMangaTitle()).catch(error => { - alert(i18n.aria2.error); - jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; - secret = prompt('Aria2 Secret Token', secret) ?? secret; - aria2 = new Aria2(jsonrpc, secret); - GM_setValue('aria2', {jsonrpc, secret}); - }); + alert(i18n.aria2.error); + jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; + secret = prompt('Aria2 Secret Token', secret) ?? secret; + aria2 = new Aria2(jsonrpc, secret); + GM_setValue('aria2', {jsonrpc, secret}); + }); if (folder) { - urls.forEach(async(url, index) => aria2.message('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, header: aria2Headers}])); + urls.forEach(async(url, index) => aria2.message('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, ...headers}])); notification('aria2', 'done'); } }); From f856e7de61b9c01c9c9d6ab47edb0089c997a59e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 5 Mar 2022 14:33:55 +0800 Subject: [PATCH 0519/1027] Update README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 3b5033e..accf4bc 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,3 @@ - Download `Tampermonkey` extension for `Chromium` or `Mozilla Firefox` - Click `Raw` then `Tampermonkey` will install the script automatically - -# Libraries - -#### [aria2request.js](libs/aria2request.md) -#### [dragndrop.js](libs/dragndrop.md) -#### [metalink.js](libs/metalink4.md) From 293e2adc5dd076d42f42e1bfd9074df0ab66c380 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Mar 2022 11:20:33 +0800 Subject: [PATCH 0520/1027] Delete dragndrop.js --- libs/dragndrop.js | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 libs/dragndrop.js diff --git a/libs/dragndrop.js b/libs/dragndrop.js deleted file mode 100644 index 02d7ac4..0000000 --- a/libs/dragndrop.js +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - this.dragndrop = ({node, top = 0, right = 0, bottom = 0, left = 0}, c) => { - var x, y, w, h; - var d = document.documentElement; - node.draggable=true; - node.addEventListener('dragstart', e => { - y = e.clientY; - x = e.clientX; - }); - node.addEventListener('dragend', e => { - h = d.clientHeight > node.offsetHeight + bottom ? d.clientHeight - node.offsetHeight - bottom : 0; - w = d.clientWidth > node.offsetWidth + right ? d.clientWidth - node.offsetWidth - right : 0; - y = node.offsetTop + e.clientY - y; - x = node.offsetLeft + e.clientX - x; - y = y < top ? top : y > h ? h : y; - x = x < left ? left : x > w ? w : x; - node.style.top = y + 'px'; - node.style.left = x + 'px'; - if (typeof c === 'function') { c(y, x); } - }); - }; -})(); From 740297624cdee10286be3d688f2b12a60b901582 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Mar 2022 11:36:13 +0800 Subject: [PATCH 0521/1027] Delete dragndrop.md --- libs/dragndrop.md | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 libs/dragndrop.md diff --git a/libs/dragndrop.md b/libs/dragndrop.md deleted file mode 100644 index 47ca900..0000000 --- a/libs/dragndrop.md +++ /dev/null @@ -1,33 +0,0 @@ -## How to implement -### HTML -```HTML - -``` -### TamperMonkey -```javascript -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= -``` -## Syntax -```javascript -dragndrop(object, callback); -``` -### `object` -An object containing information to append drag'n'drop event for an element `{ node, top, right, bottom, left }` -#### node `*required` -The target DOM node -#### top `Optional` -The offset of top `integer`, `default: 0` -#### right `Optional` -The offset of right `integer`, `default: 0` -#### bottom `Optional` -The offset of bottom `integer`, `default: 0` -#### left `Optional` -The offset of left `integer`, `default: 0` -### `callback` `function` `Optional` -A callback function with new position -```javascript -function (top, left) { - // Your code here -} -``` From 86d2b2f252057916ec4827c5c659a82b01824e8c Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Mar 2022 11:37:37 +0800 Subject: [PATCH 0522/1027] update dragndrop.js --- RawMangaAssistant.user.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 39567d4..1408239 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.13 +// @version 6.14 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -17,7 +17,7 @@ // @match *://mangameta.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2.js#sha256-/NyeHAvLqSqeD6YbfeQacGIUFZ9FPn46kWmPNmlEInU= -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= +// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest @@ -233,11 +233,14 @@ container.innerHTML = '
💾' + i18n.s document.body.append(button, container, css); // Draggable button and menu -dragndrop({node: button}, (top, left) => { - container.style.top = top + 'px'; - container.style.left = left + button.offsetWidth + 'px'; - GM_setValue('options', {...options, top, left}); -}); +var dragndrop = new DragNDrop(button); +dragndrop.ondragend = event => { + container.style.top = dragndrop.offsetTop + 'px'; + container.style.left = dragndrop.offsetLeft + button.offsetWidth + 'px'; + options.top = dragndrop.offsetTop; + options.left = dragndrop.offsetLeft; + GM_setValue('options', options); +}; container.querySelector('#download').addEventListener('click', event => { urls.forEach((url, index) => { From 614bc298d685a616d5b2448468060c10849ab2e3 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Mar 2022 11:40:42 +0800 Subject: [PATCH 0523/1027] update dragndrop.js --- SpeedRunHelper.user.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index af90b79..33662cf 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.1 +// @version 3.2 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/dragndrop.js#sha256-NkLbP8qGlQ6SEBaf0HeiUVT+5/kXjyJYaSwd28Dj9zA= +// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.scorecardresearch.com/*", "action": "cancel"} @@ -106,12 +106,13 @@ function createRecordWindow(id, title, content) { container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); }); - dragndrop({node: container, top: document.querySelector('nav').parentNode.offsetHeight}, () => { + var dragndrop = new DragNDrop(container, document.querySelector('nav').parentNode.offsetHeight); + dragndrop.ondragend = event => { if (container.className === 'speedrun-window') { style[id] = container.style.cssText; } else { container.style.cssText = ''; } - }); + }; } From 0e7d30e659034b9b0de18dba947edcb2bf1ac652 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Mar 2022 13:11:12 +0800 Subject: [PATCH 0524/1027] clean up --- NarouSyosetuManager.user.js | 56 +++++++++---------------------------- 1 file changed, 13 insertions(+), 43 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 4e232da..19e4376 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -6,7 +6,7 @@ // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/userscript/main/libs/metalink4.js#sha256-sJFxO/Xi8lu3msbA2J9h46fvpHdacjfmKZ1xJ8AauDM= +// @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/metalink4.js#sha256-6oj9bI0kPdhk0XE8OEW9VWwedwSdFxjIirpGaFTAq0A= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue @@ -54,12 +54,7 @@ manager.addEventListener('click', event => { bookmark.forEach(fancyTableItem); show = true; } - if (manager.classList.contains('manager-checked')) { - container.style.display = 'none'; - } - else { - container.style.display = 'block'; - } + container.style.display = manager.classList.contains('manager-checked') ? 'none' : 'block'; manager.classList.toggle('manager-checked'); }); (document.getElementById('head_nav') ?? document.body).appendChild(manager); @@ -102,7 +97,7 @@ container.querySelector('#mgr-btn-meta4').addEventListener('click', event => { container.querySelector('#' + book.ncode).lastChild.innerHTML = generateTimeFormat(novelist.now); return {url: ['https://pdfnovels.net/' + book.ncode + '/main.pdf'], name: book.title + '.pdf', locale: 'ja'}; }); - toMetalink4(json).saveAs('小説家になろう書庫'); + new Metalink4(json).saveAs('小説家になろう書庫'); saveBookmarkButton(); alert('情報のエックスポートは無事に成功しました!'); } @@ -114,29 +109,17 @@ container.querySelector('#mgr-btn-save').addEventListener('click', event => { container.querySelector('.manager-button:nth-child(6)').style.display = 'none'; }); container.querySelector('#mgr-btn-log').addEventListener('click', event => { - if (event.target.classList.contains('manager-checked')) { - container.querySelector('.manager-logs').style.display = 'none'; - container.querySelector('.manager-shelf').style.display = 'block'; - } - else { - container.querySelector('.manager-logs').style.display = 'block'; - container.querySelector('.manager-shelf').style.display = 'none'; - } + container.querySelector('.manager-logs').style.display = event.target.classList.contains('manager-checked') ? 'none' : 'block'; + container.querySelector('.manager-shelf').style.display = event.target.classList.contains('manager-checked') ? 'block' : 'none'; event.target.classList.toggle('manager-checked'); }); // NCODE検証&登録 function validateNcode(ncode) { if (validate[ncode]) { - if (validate[ncode] === '検証中') { - myFancyPopup('', 'Nコード' + ncode, 'は既に検証しています、何度もクリックしないでください!'); - } - else if (validate[ncode] === 'エラー') { - myFancyPopup('', 'Nコード' + ncode, 'は存在しないか既にサーバーから削除されています!'); - } - else { - subscribeNcode(ncode, validate[ncode]); - } + validate[ncode] === '検証中' ? myFancyPopup('', 'Nコード' + ncode, 'は既に検証しています、何度もクリックしないでください!') : + validate[ncode] === 'エラー' ? myFancyPopup('', 'Nコード' + ncode, 'は存在しないか既にサーバーから削除されています!') : + subscribeNcode(ncode, validate[ncode]); return; } validate[ncode] = '検証中'; @@ -188,14 +171,8 @@ function fancyTableItem(book, index) { mybook.addEventListener('change', event => { book.next = parseInt(event.target.value); saveBookmarkButton(); - if (book.next === 0) { - event.target.title = '自動更新をしません'; - myFancyLog(book.ncode, book.title, 'は更新しないように設定しました!'); - } - else { - event.target.title = book.next + '日間隔で更新します'; - myFancyLog(book.ncode, book.title, 'は ' + book.next + ' 日間隔で更新するように設定しました!'); - } + event.target.title = book.next === 0 ? '自動更新をしません' : book.next + '日間隔で更新します'; + myFancyLog(book.ncode, book.title, book.next === 0 ? 'は更新しないように設定しました!' : 'は ' + book.next + ' 日間隔で更新するように設定しました!'); }); } function generateTimeFormat(ms) { @@ -318,16 +295,9 @@ function myFancyPopup(ncode, title, result) { setTimeout(() => removePopup(popup), 5000); } function myFancyNcode(ncode, title) { - if (ncode && title) { - return '「' + title + '」'; - } - if (!ncode && title) { - return '' + title + ''; - } - if (ncode && !title) { - return '' + ncode + ''; - } - return ''; + return ncode && title ? '「' + title + '」' : + !ncode && title ? '' + title + '' : + ncode && !title ? '' + ncode + '' : ''; } function alignFancyPopup() { document.querySelectorAll('.notification').forEach((element, index) => { From 821c3bf8dd977ce54d4099a1ca0ff7df15087cf5 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 8 Mar 2022 13:21:32 +0800 Subject: [PATCH 0525/1027] clean up --- NarouSyosetuManager.user.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 19e4376..61dfb65 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 小説家になろう 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 4.7 +// @version 4.8 // @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* @@ -105,8 +105,7 @@ container.querySelector('#mgr-btn-meta4').addEventListener('click', event => { container.querySelector('#mgr-btn-save').addEventListener('click', event => { GM_setValue('bookmark', bookmark); container.querySelector('.manager-logs').innerHTML = ''; - container.querySelector('.manager-button:nth-child(5)').style.display = 'none'; - container.querySelector('.manager-button:nth-child(6)').style.display = 'none'; + container.querySelector('#mgr-btn-save').style.display = container.querySelector('#mgr-btn-log').style.display = 'none'; }); container.querySelector('#mgr-btn-log').addEventListener('click', event => { container.querySelector('.manager-logs').style.display = event.target.classList.contains('manager-checked') ? 'none' : 'block'; @@ -180,8 +179,7 @@ function generateTimeFormat(ms) { return time.getFullYear() + '/' + (time.getMonth() + 1) + '/' + time.getDate() + '\n' + time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds(); } function saveBookmarkButton() { - container.querySelector('.manager-button:nth-child(5)').style.display = 'inline-block'; - container.querySelector('.manager-button:nth-child(6)').style.display = 'inline-block'; + container.querySelector('#mgr-btn-save').style.display = container.querySelector('#mgr-btn-log').style.display = 'inline-block'; } // PDF自動更新関連 From 692797d940c31fbf700de5840ec239158a9c4ac3 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 9 Mar 2022 11:23:46 +0800 Subject: [PATCH 0526/1027] add options --- BilibiliVideoDownloader.user.js | 126 +++++++++++++++++++------------- 1 file changed, 74 insertions(+), 52 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 802ca54..ef951e8 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,13 +2,15 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 2.19 +// @version 3.0 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 // @match *://www.bilibili.com/video/* // ==/UserScript== +var {autowide = '0', videocodec = '0'} = localStorage; +var title; var format = { '30280': {label: '音频 高码率', ext: '.192k.aac'}, '30232': {label: '音频 中码率', ext: '.128k.aac'}, @@ -28,45 +30,57 @@ var format = { 'mp4a': '音频编码: AAC' }; -var title = ''; -var menu = document.createElement('div'); -menu.id = 'download-box'; -var thumb = document.createElement('div'); -var video = document.createElement('div'); -var audio = document.createElement('div'); -menu.append(thumb, video, audio); - var css = document.createElement('style'); -css.innerHTML = '#download-box > * {position: relative; display: inline-block; margin: -5px 1px 5px; height: 38px; overflow-y: hidden; vertical-align: top;}\ -#download-box > *:hover {height: max-content; z-index: 999999;}\ -#download-box a {background-color: #c26; color: #fff; display: block; margin-top: 1px; font-size: 16px; height: 16px; line-height: 16px; padding: 10px; text-align: center;}\ -#download-box a:hover {background-color: #26c;}'; +css.innerHTML = '#helper-main {background-color: #fff; position: relative; z-index: 9999; display: inline-block; user-select: none;}\ +#helper-options, #helper-analyse {position: relative; border: 1px solid #000; padding: 5px;}\ +#helper-options p, #helper-options select, .helper-button {font-size: 16px; text-align: center; padding: 5px;}\ +#helper-options select {width: 100%;}\ +#helper-analyse ul {display: inline-block; margin-righ: 3px; vertical-align: top;}\ +.helper-button {background-color: #c26; color: #fff; height: 16px; line-height: 16px; padding: 10px 15px; display: inline-block; margin-right: 3px; cursor: pointer;}\ +.helper-button:hover {background-color: #26c;}'; + +var menu = document.createElement('div'); +menu.id = 'helper-main'; +menu.innerHTML = '设置解析'; +menu.querySelector('#options').addEventListener('click', event => { + analyse.style.display = 'none'; + options.style.display = options.style.display === 'none' ? 'block' : 'none'; +}); +menu.querySelector('#analyse').addEventListener('click', event => { + options.style.display = 'none'; + analyse.style.display = analyse.style.display === 'none' ? 'block' : 'none'; + analyse.innerHTML = '
        '; + title = ''; + var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; + if (aid && cid) { + biliVideoTitle(videoData.title); + biliVideoThumbnail(elecFullInfo.data.pic); + biliVideoExtractor('x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'); + } + else { + biliVideoTitle(h1Title); + biliVideoThumbnail(epInfo.cover); + biliVideoExtractor('pgc/player/web/playurl?ep_id=' + epInfo.id, 'result'); + } +}); +var options = document.createElement('div'); +options.id = 'helper-options'; +options.innerHTML = '

        自动宽屏

        \ +

        优先编码

        '; +options.querySelector('#autowide').value = autowide; +options.querySelector('#videocodec').value = videocodec; +options.addEventListener('change', event => { + localStorage[event.target.id] = event.target.value; +}); +var analyse = document.createElement('div'); +analyse.id = 'helper-analyse'; +menu.append(options, analyse, css); +options.style.display = analyse.style.display = 'none'; setTimeout(() => { - var player = document.querySelector('video') ?? document.querySelector('bwp-video'); var toolbar = document.querySelector('#arc_toolbar_report') ?? document.querySelector('#toolbar_module'); - player.addEventListener('progress', () => { - if (title === '') { - var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; - if (aid && cid) { - biliVideoTitle(videoData.title); - biliVideoThumbnail(elecFullInfo.data.pic); - biliVideoExtractor('x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'); - biliVideoAutoWide('div.bilibili-player-video-btn-widescreen', 'closed'); - menu.style.cssText = 'position: relative; top: 5px;'; - } - else { - biliVideoTitle(h1Title); - biliVideoThumbnail(epInfo.cover); - biliVideoExtractor('pgc/player/web/playurl?ep_id=' + epInfo.id, 'result'); - biliVideoAutoWide('div.squirtle-video-widescreen', 'active'); - } - } - }); - player.addEventListener('loadstart', () => { - thumb.innerHTML = video.innerHTML = audio.innerHTML = title = ''; - }); toolbar.append(menu, css); + document.defaultView.cid ? biliVideoAutoWide('div.bilibili-player-video-btn-widescreen', 'closed') : biliVideoAutoWide('div.squirtle-video-widescreen', 'active'); }, 1500); function biliVideoTitle(name) { @@ -76,33 +90,41 @@ function biliVideoTitle(name) { function biliVideoAutoWide(wide, active) { setTimeout(() => { - if (!document.querySelector(wide).classList.contains(active)) { document.querySelector(wide).click(); } - }, 1500); + if (document.querySelector(wide).classList.contains(active) || autowide === '0' ) { + return; + } + document.querySelector(wide).click(); + }, 2500); } function biliVideoThumbnail(url) { var menu = createMenuitem('视频封面', url, url.slice(url.lastIndexOf('.'))); - thumb.appendChild(menu); + analyse.querySelector('#helper-thumb').appendChild(menu); } function biliVideoExtractor(param, key) { fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}).then(response => response.json()).then(json => { - [...json[key].dash.video, ...json[key].dash.audio].forEach(meta => { - var menu = meta.mimeType.startsWith('video') ? video : audio; - var {label, ext} = format[meta.id]; - var codec = meta.codecs.slice(0, meta.codecs.indexOf('.')); - var item = createMenuitem(label, meta.baseUrl, '.' + codec + ext, codec); - menu.appendChild(item); + json[key].dash.video.forEach(({id, mimeType, codecs, baseUrl}) => { + var codec = codecs.slice(0, codecs.indexOf('.')); + if (codec === 'avc1' && videocodec !== '0' || codec === 'hev1' && videocodec !== '1') { + return; + } + var {label, ext} = format[id]; + var item = createMenuitem(label, baseUrl, '.' + codec + ext, codec); + analyse.querySelector('#helper-video').appendChild(item); }); - }) + json[key].dash.audio.forEach(({id, mimeType, codecs, baseUrl}) => { + var codec = codecs.slice(0, codecs.indexOf('.')); + var {label, ext} = format[id]; + var item = createMenuitem(label, baseUrl, '.' + codec + ext, codec); + analyse.querySelector('#helper-audio').appendChild(item); + }) + }); } function createMenuitem(label, url, ext, codec) { - var item = document.createElement('a'); - item.href = url; - item.target = '_blank'; - item.download = title; - item.innerText = label; - item.title = codec === undefined ? '' : format[codec] ? format[codec] : '未知编码: ' + codec; - return item; + var li = document.createElement('li'); + var tip = codec === undefined ? '' : format[codec] ? format[codec] : '未知编码: ' + codec; + li.innerHTML = '' + label + ''; + return li; } From 739d1e0c944c90c2af31ba1bb60297b8c046f972 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 9 Mar 2022 15:51:10 +0800 Subject: [PATCH 0527/1027] fixed auto wide --- BilibiliVideoDownloader.user.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index ef951e8..e85731d 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.0 +// @version 3.1 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -78,9 +78,11 @@ menu.append(options, analyse, css); options.style.display = analyse.style.display = 'none'; setTimeout(() => { + var player = document.querySelector('video') ?? document.querySelector('bwp-video'); var toolbar = document.querySelector('#arc_toolbar_report') ?? document.querySelector('#toolbar_module'); toolbar.append(menu, css); - document.defaultView.cid ? biliVideoAutoWide('div.bilibili-player-video-btn-widescreen', 'closed') : biliVideoAutoWide('div.squirtle-video-widescreen', 'active'); + player.addEventListener('loadstart', biliVideoAutoWide); + biliVideoAutoWide(); }, 1500); function biliVideoTitle(name) { @@ -88,13 +90,14 @@ function biliVideoTitle(name) { title = (name + (multi ? multi.innerText : '')).replace(/[\/\\\?\|\<\>:"']/g, ''); } -function biliVideoAutoWide(wide, active) { +function biliVideoAutoWide() { setTimeout(() => { - if (document.querySelector(wide).classList.contains(active) || autowide === '0' ) { + var wide = document.querySelector('div.bilibili-player-video-btn-widescreen') ?? document.querySelector('div.squirtle-video-widescreen'); + if (wide.classList.contains('closed') || wide.classList.contains('active') || autowide === '0' ) { return; } - document.querySelector(wide).click(); - }, 2500); + wide.click(); + }, 1500); } function biliVideoThumbnail(url) { From 6982a8d7575504c5b009de51af923642e6fbcef6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 9 Mar 2022 17:19:41 +0800 Subject: [PATCH 0528/1027] add video extract fallback to h264 --- BilibiliVideoDownloader.user.js | 52 +++++++++++++++------------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index e85731d..d1a0779 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.1 +// @version 3.2 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -11,6 +11,7 @@ var {autowide = '0', videocodec = '0'} = localStorage; var title; +var video; var format = { '30280': {label: '音频 高码率', ext: '.192k.aac'}, '30232': {label: '音频 中码率', ext: '.128k.aac'}, @@ -46,22 +47,20 @@ menu.querySelector('#options').addEventListener('click', event => { analyse.style.display = 'none'; options.style.display = options.style.display === 'none' ? 'block' : 'none'; }); -menu.querySelector('#analyse').addEventListener('click', event => { +menu.querySelector('#analyse').addEventListener('click', async event => { options.style.display = 'none'; - analyse.style.display = analyse.style.display === 'none' ? 'block' : 'none'; - analyse.innerHTML = '
              '; - title = ''; - var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; - if (aid && cid) { - biliVideoTitle(videoData.title); - biliVideoThumbnail(elecFullInfo.data.pic); - biliVideoExtractor('x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'); - } - else { - biliVideoTitle(h1Title); - biliVideoThumbnail(epInfo.cover); - biliVideoExtractor('pgc/player/web/playurl?ep_id=' + epInfo.id, 'result'); + if (video !== location.pathname || videocodec !== localStorage.videocodec) { + video = location.pathname; + videocodec = localStorage.videocodec; + analyse.innerHTML = '
                    '; + title = ''; + var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; + var [title, thumb, playurl, key] = aid && cid ? [videoData.title, elecFullInfo.data.pic, 'x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; + biliVideoTitle(title); + biliVideoThumbnail(thumb); + await biliVideoExtractor(playurl, key); } + analyse.style.display = analyse.style.display === 'none' ? 'block' : 'none'; }); var options = document.createElement('div'); options.id = 'helper-options'; @@ -105,24 +104,19 @@ function biliVideoThumbnail(url) { analyse.querySelector('#helper-thumb').appendChild(menu); } -function biliVideoExtractor(param, key) { - fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}).then(response => response.json()).then(json => { - json[key].dash.video.forEach(({id, mimeType, codecs, baseUrl}) => { +async function biliVideoExtractor(param, key) { + var menu = {av1: [], hevc: [], avc: [], aac: []}; + await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}).then(response => response.json()).then(({[key]: {dash: {video, audio}}}) => { + [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); - if (codec === 'avc1' && videocodec !== '0' || codec === 'hev1' && videocodec !== '1') { - return; - } + var array = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av1' ? menu.av1 : menu.aac; var {label, ext} = format[id]; - var item = createMenuitem(label, baseUrl, '.' + codec + ext, codec); - analyse.querySelector('#helper-video').appendChild(item); + array.push(createMenuitem(label, baseUrl, '.' + codec + ext, codec)); }); - json[key].dash.audio.forEach(({id, mimeType, codecs, baseUrl}) => { - var codec = codecs.slice(0, codecs.indexOf('.')); - var {label, ext} = format[id]; - var item = createMenuitem(label, baseUrl, '.' + codec + ext, codec); - analyse.querySelector('#helper-audio').appendChild(item); - }) }); + var video = videocodec === '2' && menu.av1.length !== 0 ? menu.av1 : videocodec === '1' && menu.hevc.length !== 0 ? menu.hevc : menu.avc; + video.forEach(item => document.querySelector('#helper-video').appendChild(item)); + menu.aac.forEach(item => document.querySelector('#helper-audio').appendChild(item)); } function createMenuitem(label, url, ext, codec) { From 3d5fae4061f32d0ecd5758ad34b3b28745d79d7d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 10 Mar 2022 10:44:14 +0800 Subject: [PATCH 0529/1027] fixed autowide and css --- BilibiliVideoDownloader.user.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index d1a0779..4397db9 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.2 +// @version 3.3 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -37,7 +37,8 @@ css.innerHTML = '#helper-main {background-color: #fff; position: relative; z-ind #helper-options p, #helper-options select, .helper-button {font-size: 16px; text-align: center; padding: 5px;}\ #helper-options select {width: 100%;}\ #helper-analyse ul {display: inline-block; margin-righ: 3px; vertical-align: top;}\ -.helper-button {background-color: #c26; color: #fff; height: 16px; line-height: 16px; padding: 10px 15px; display: inline-block; margin-right: 3px; cursor: pointer;}\ +#helper-analyse a {display: inline-block; width: 100px;}\ +.helper-button {background-color: #c26; color: #fff; height: 16px; line-height: 16px; padding: 10px 15px; display: inline-block; margin: 0px 3px 3px 0px; cursor: pointer;}\ .helper-button:hover {background-color: #26c;}'; var menu = document.createElement('div'); @@ -90,13 +91,16 @@ function biliVideoTitle(name) { } function biliVideoAutoWide() { - setTimeout(() => { + var observer = setInterval(() => { var wide = document.querySelector('div.bilibili-player-video-btn-widescreen') ?? document.querySelector('div.squirtle-video-widescreen'); - if (wide.classList.contains('closed') || wide.classList.contains('active') || autowide === '0' ) { - return; + if (wide) { + clearInterval(observer); + if (wide.classList.contains('closed') || wide.classList.contains('active') || autowide === '0' ) { + return; + } + wide.click(); } - wide.click(); - }, 1500); + }, 500); } function biliVideoThumbnail(url) { From 66b43f8fa26b5f3e21460089d4cdc535de67892a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 10 Mar 2022 10:50:28 +0800 Subject: [PATCH 0530/1027] better ui --- BilibiliVideoDownloader.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 4397db9..4d500fa 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.3 +// @version 3.4 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -35,6 +35,7 @@ var css = document.createElement('style'); css.innerHTML = '#helper-main {background-color: #fff; position: relative; z-index: 9999; display: inline-block; user-select: none;}\ #helper-options, #helper-analyse {position: relative; border: 1px solid #000; padding: 5px;}\ #helper-options p, #helper-options select, .helper-button {font-size: 16px; text-align: center; padding: 5px;}\ +#helper-options p, #helper-options option:checked {color: #c26; font-weight: bold;}\ #helper-options select {width: 100%;}\ #helper-analyse ul {display: inline-block; margin-righ: 3px; vertical-align: top;}\ #helper-analyse a {display: inline-block; width: 100px;}\ From 6d214dd3146d09241258df6b356657b72a8059b6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 13 Mar 2022 21:04:11 +0800 Subject: [PATCH 0531/1027] better logic for auto wide --- BilibiliVideoDownloader.user.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 4d500fa..7e8291c 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.4 +// @version 3.5 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -78,13 +78,17 @@ analyse.id = 'helper-analyse'; menu.append(options, analyse, css); options.style.display = analyse.style.display = 'none'; +new MutationObserver(mutations => { + if (video !== location.pathname) { + video = location.pathname; + biliVideoAutoWide(); + } +}).observe(document.head, {childList: true, subtree: true}); + setTimeout(() => { - var player = document.querySelector('video') ?? document.querySelector('bwp-video'); var toolbar = document.querySelector('#arc_toolbar_report') ?? document.querySelector('#toolbar_module'); toolbar.append(menu, css); - player.addEventListener('loadstart', biliVideoAutoWide); - biliVideoAutoWide(); -}, 1500); +}, 2000); function biliVideoTitle(name) { var multi = document.querySelector('#multi_page li.on > a'); From faa1d08466d1369a778cedc7e8db2af530ad7428 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 13 Mar 2022 21:18:13 +0800 Subject: [PATCH 0532/1027] fixed analyse --- BilibiliVideoDownloader.user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 7e8291c..40e4c9c 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -12,6 +12,7 @@ var {autowide = '0', videocodec = '0'} = localStorage; var title; var video; +var worker; var format = { '30280': {label: '音频 高码率', ext: '.192k.aac'}, '30232': {label: '音频 中码率', ext: '.128k.aac'}, @@ -51,11 +52,10 @@ menu.querySelector('#options').addEventListener('click', event => { }); menu.querySelector('#analyse').addEventListener('click', async event => { options.style.display = 'none'; - if (video !== location.pathname || videocodec !== localStorage.videocodec) { - video = location.pathname; + if (worker || videocodec !== localStorage.videocodec) { + worker = false; videocodec = localStorage.videocodec; analyse.innerHTML = '
                          '; - title = ''; var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; var [title, thumb, playurl, key] = aid && cid ? [videoData.title, elecFullInfo.data.pic, 'x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; biliVideoTitle(title); @@ -81,6 +81,7 @@ options.style.display = analyse.style.display = 'none'; new MutationObserver(mutations => { if (video !== location.pathname) { video = location.pathname; + worker = true; biliVideoAutoWide(); } }).observe(document.head, {childList: true, subtree: true}); From 22246b554d136047214d638de9ae830538e50951 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 22 Mar 2022 09:43:27 +0800 Subject: [PATCH 0533/1027] new video should close anayse and options --- BilibiliVideoDownloader.user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 40e4c9c..e22d08c 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.5 +// @version 3.6 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -82,6 +82,7 @@ new MutationObserver(mutations => { if (video !== location.pathname) { video = location.pathname; worker = true; + options.style.display = analyse.style.display = 'none'; biliVideoAutoWide(); } }).observe(document.head, {childList: true, subtree: true}); @@ -133,5 +134,6 @@ function createMenuitem(label, url, ext, codec) { var li = document.createElement('li'); var tip = codec === undefined ? '' : format[codec] ? format[codec] : '未知编码: ' + codec; li.innerHTML = '' + label + ''; + li.addEventListener('click', event => navigator.clipboard.writeText(title)); return li; } From a7425ad7d757669adb128a433ad01f9d1d38c617 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 22 Mar 2022 10:26:36 +0800 Subject: [PATCH 0534/1027] fixed download attr --- BilibiliVideoDownloader.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index e22d08c..91ae7b5 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -133,7 +133,7 @@ async function biliVideoExtractor(param, key) { function createMenuitem(label, url, ext, codec) { var li = document.createElement('li'); var tip = codec === undefined ? '' : format[codec] ? format[codec] : '未知编码: ' + codec; - li.innerHTML = '' + label + ''; + li.innerHTML = '' + label + ''; li.addEventListener('click', event => navigator.clipboard.writeText(title)); return li; } From 129f6f7d7c39f7eb1350e1c3fbb9e678a0355ee4 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 24 Mar 2022 18:23:54 +0800 Subject: [PATCH 0535/1027] update css --- NarouSyosetuManager.user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 61dfb65..610ba8d 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -38,8 +38,9 @@ css.innerHTML = '.manager-button {background-color: #fff; text-align: center; ve .manager-menu input {height: 20px;}\ .manager-container > div:nth-child(n+2) {margin-top: 5px;}\ .manager-shelf, .manager-logs {overflow-y: scroll; height: 552px;}\ -.manager-shelf > * {display: grid; grid-template-columns: 100px calc(100% - 300px) 100px 100px; text-align: center;}\ -.manager-shelf > *:nth-child(2n+1):not(:first-child) * {background-color: #eee;}\ +.manager-shelf > * {display: grid; grid-template-columns: 100px calc(100% - 306px) 100px 100px; grid-column-gap: 2px; text-align: center;}\ +.manager-shelf > *:first-child > * {background-color: #000; color: #fff;}\ +.manager-shelf > *:nth-child(2n+1):not(:first-child) > * {background-color: #eee;}\ .manager-shelf > *:not(:first-child) > *:nth-child(2) {text-align: left;}\ .manager-shelf > *:not(:first-child) > *:nth-child(1) {line-height: 40px;}\ .notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff;}'; @@ -66,7 +67,7 @@ container.innerHTML = '
                          NCODEをエックスポート\ \
                          \ -
                          NCODE小説タイトル更新間隔ダウンロード
                          \ +
                          NCODE小説タイトル更新間隔ダウンロード
                          \ '; container.className = 'manager-container'; container.style.cssText = 'display: none;'; From 6c2c6971856ebc3f48e216efe1e2adbf1edd2639 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 30 Mar 2022 14:26:45 +0800 Subject: [PATCH 0536/1027] update libs and storage --- RawMangaAssistant.user.js | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 1408239..39fbe27 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.14 +// @version 6.15 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -16,10 +16,8 @@ // @match *://weloma.net/* // @match *://mangameta.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2.js#sha256-/NyeHAvLqSqeD6YbfeQacGIUFZ9FPn46kWmPNmlEInU= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.6.js#sha256-KJZqM++cM/ynXn4uSmC8eo0PfsXg8lFkZisk8U3zVLs= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= -// @grant GM_getValue -// @grant GM_setValue // @grant GM_xmlhttpRequest // @grant GM_webRequest // @webRequest {"selector": "*.googlesyndication.com/*", "action": "cancel"} @@ -60,13 +58,12 @@ var logo = []; var observer; var images; var watching; -var {jsonrpc, secret} = GM_getValue('aria2', {jsonrpc: 'http://localhost:6800/jsonrpc', secret: ''}); -var aria2 = new Aria2(jsonrpc, secret); +var aria2 = new Aria2(localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc', localStorage.secret ?? ''); var folder; -var options = GM_getValue('options', {menu: 'on', top: 300, left: 150}); -var offset; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; +var iconTop = localStorage.offsetTop ? localStorage.offsetTop | 0 : 350; +var iconLeft = localStorage.offsetLeft ? localStorage.offsetLeft | 0 : 200; // i18n strings and labels var message = { @@ -203,8 +200,8 @@ function extractMangaTitle(title = '') { // Create UI var css = document.createElement('style'); css.innerHTML = '#assistant_button, #assistant_container, #assistant_caution {background-color: #fff; color: #000; position: fixed; z-index: 999999999;}\ -#assistant_button {text-align: center; line-height: 42px; width: 42px !important; height: 42px !important; border: 1px solid darkviolet; top: ' + options.top + 'px; left: ' + options.left + 'px;}\ -#assistant_container {top: ' + options.top + 'px; left: ' + (options.left + 42) + 'px; display: none;}\ +#assistant_button {text-align: center; line-height: 42px; width: 42px !important; height: 42px !important; border: 1px solid darkviolet; top: ' + iconTop + 'px; left: ' + iconLeft + 'px;}\ +#assistant_container {top: ' + iconTop + 'px; left: ' + (iconLeft + 42) + 'px; display: none;}\ #assistant_container > * {background-color: #fff; width: 220px; border: 1px ridge darkblue; font-size: 14px;}\ #assistant_container > *:nth-child(-n+2), #assistant_container data {display: none;}\ #assistant_container.extract > *:nth-child(-n+2), #assistant_container .checked data {display: block;}\ @@ -237,9 +234,8 @@ var dragndrop = new DragNDrop(button); dragndrop.ondragend = event => { container.style.top = dragndrop.offsetTop + 'px'; container.style.left = dragndrop.offsetLeft + button.offsetWidth + 'px'; - options.top = dragndrop.offsetTop; - options.left = dragndrop.offsetLeft; - GM_setValue('options', options); + localStorage.offsetTop = dragndrop.offsetTop; + localStorage.offsetLeft = dragndrop.offsetLeft; }; container.querySelector('#download').addEventListener('click', event => { @@ -271,10 +267,9 @@ container.querySelector('#scrolltop').addEventListener('click', event => { container.querySelector('#aria2download').addEventListener('click', async event => { folder = folder ?? await aria2.message('aria2.getGlobalOption').then(({dir}) => dir + extractMangaTitle()).catch(error => { alert(i18n.aria2.error); - jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; - secret = prompt('Aria2 Secret Token', secret) ?? secret; - aria2 = new Aria2(jsonrpc, secret); - GM_setValue('aria2', {jsonrpc, secret}); + localStorage.jsonrpc = prompt('Aria2 JSONRPC URI', localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc') ?? localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc'; + localStorage.secret = prompt('Aria2 Secret Token', localStorage.secret ?? '') ?? localStorage.secret ?? ''; + aria2 = new Aria2(localStorage.jsonrpc, localStorage.secret); }); if (folder) { urls.forEach(async(url, index) => aria2.message('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, ...headers}])); @@ -286,7 +281,7 @@ container.querySelector('#aria2download').addEventListener('click', async event var switchMenu = document.createElement('div'); [ { - name: 'menu', + name: 'contextmenu', on: () => { button.style.display = 'none'; document.addEventListener('contextmenu', contextMenuHandler); @@ -303,7 +298,7 @@ var switchMenu = document.createElement('div'); menu.setAttribute('name', name); menu.innerHTML = '' + i18n.menu.label + '
                          '; menu.addEventListener('click', event => { - options[name] = options[name] === 'on' ? 'off' : 'on'; + localStorage[name] = localStorage[name] === 'on' ? 'off' : 'on'; switchHandler(menu, name, on, off); GM_setValue('options', options); }); @@ -313,7 +308,7 @@ var switchMenu = document.createElement('div'); container.appendChild(switchMenu); function switchHandler(menu, name, on, off) { - if (options[name] === 'on') { + if (localStorage[name] === 'on') { on(); menu.classList.add('checked'); } From 4ea4ccad2ada43f9bfbe9f9ecf594e38056bb894 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 1 Apr 2022 11:05:57 +0800 Subject: [PATCH 0537/1027] add new site support --- RawMangaAssistant.user.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 39fbe27..9b8452c 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.15 +// @version 6.16 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -15,6 +15,7 @@ // @match *://weloma.art/* // @match *://weloma.net/* // @match *://mangameta.com/* +// @match *://mangagohan.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.6.js#sha256-KJZqM++cM/ynXn4uSmC8eo0PfsXg8lFkZisk8U3zVLs= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= @@ -173,6 +174,11 @@ var manga = { image: 'div.chapter-c > img', title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, shortcut: 'div.linkchap > a' + }, + 'mangagohan.com': { + image: 'div.page-break > img', + lazyload: 'data-src', + title: {reg: /^(.+)\s\(Raw\s–\sFree\)\s-[^\d]+(\d+)/, sel: 'meta[property="og:title"]', attr: 'content', tl: 1, ch: 2} } }; manga['manga1001.com'] = manga['manga1000.com']; From db4e8690c77a2e85858d5249e0e7863fb7d48ad8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 1 Apr 2022 11:44:48 +0800 Subject: [PATCH 0538/1027] changed site support --- RawMangaAssistant.user.js | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 9b8452c..d31b00e 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -6,19 +6,19 @@ // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 -// @match *://ja.mangatoro.com/* // @match *://mikaraw.com/* // @match *://klmag.net/* // @match *://rawdevart.com/* // @match *://manga1000.com/* // @match *://manga1001.com/* -// @match *://weloma.art/* -// @match *://weloma.net/* +// @match *://welovemanga.one/* // @match *://mangameta.com/* // @match *://mangagohan.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.6.js#sha256-KJZqM++cM/ynXn4uSmC8eo0PfsXg8lFkZisk8U3zVLs= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= +// @grant GM_getValue +// @grant GM_setValue // @grant GM_xmlhttpRequest // @grant GM_webRequest // @webRequest {"selector": "*.googlesyndication.com/*", "action": "cancel"} @@ -59,12 +59,12 @@ var logo = []; var observer; var images; var watching; +var options = GM_getValue('options', {contextmenu: 'on'}); +var {jsonrpc = 'http://localhost:6800/jsonrpc', secret = '', iconTop = 350, iconLeft = 200} = options; var aria2 = new Aria2(localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc', localStorage.secret ?? ''); var folder; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; -var iconTop = localStorage.offsetTop ? localStorage.offsetTop | 0 : 350; -var iconLeft = localStorage.offsetLeft ? localStorage.offsetLeft | 0 : 200; // i18n strings and labels var message = { @@ -135,11 +135,6 @@ var i18n = message[navigator.language] ?? message['en-US']; // Supported sites var manga = { - 'ja.mangatoro.com': { - image: 'div.page-chapter > img', - lazyload: 'data-original', - title: {reg: /^(.+)\schap\s([^\s]+)/, sel: 'div.page-chapter > img', attr: 'alt', tl: 1, ch: 2} - }, 'mikaraw.com': { image: 'div.chapter-c > img', lazyload: 'data-src', @@ -164,7 +159,7 @@ var manga = { title: {reg: /^(.+)\s-\sRaw\s【第(.+)話】/, sel: 'img.aligncenter', attr: 'alt', tl: 1, ch: 2}, shortcut: 'div.linkchap > a' }, - 'weloma.art': { + 'welovemanga.one': { image: 'img.chapter-img', lazyload: 'data-srcset', title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, @@ -182,7 +177,6 @@ var manga = { } }; manga['manga1001.com'] = manga['manga1000.com']; -manga['weloma.net'] = manga['weloma.art']; watching = manga[location.host]; function longDecimalNumber(input, length = 3) { @@ -240,8 +234,9 @@ var dragndrop = new DragNDrop(button); dragndrop.ondragend = event => { container.style.top = dragndrop.offsetTop + 'px'; container.style.left = dragndrop.offsetLeft + button.offsetWidth + 'px'; - localStorage.offsetTop = dragndrop.offsetTop; - localStorage.offsetLeft = dragndrop.offsetLeft; + iconTop = dragndrop.offsetTop; + iconLeft = dragndrop.offsetLeft; + GM_setValue('options', {...options, iconTop, iconLeft}); }; container.querySelector('#download').addEventListener('click', event => { @@ -273,9 +268,10 @@ container.querySelector('#scrolltop').addEventListener('click', event => { container.querySelector('#aria2download').addEventListener('click', async event => { folder = folder ?? await aria2.message('aria2.getGlobalOption').then(({dir}) => dir + extractMangaTitle()).catch(error => { alert(i18n.aria2.error); - localStorage.jsonrpc = prompt('Aria2 JSONRPC URI', localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc') ?? localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc'; - localStorage.secret = prompt('Aria2 Secret Token', localStorage.secret ?? '') ?? localStorage.secret ?? ''; - aria2 = new Aria2(localStorage.jsonrpc, localStorage.secret); + jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; + secret = prompt('Aria2 Secret Token', secret ) ?? secret; + aria2 = new Aria2(jsonrpc, secret); + GM_setValue('options', {...options, jsonrpc, secret}); }); if (folder) { urls.forEach(async(url, index) => aria2.message('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, ...headers}])); @@ -304,7 +300,7 @@ var switchMenu = document.createElement('div'); menu.setAttribute('name', name); menu.innerHTML = '' + i18n.menu.label + '
                          '; menu.addEventListener('click', event => { - localStorage[name] = localStorage[name] === 'on' ? 'off' : 'on'; + options[name] = options[name] === 'on' ? 'off' : 'on'; switchHandler(menu, name, on, off); GM_setValue('options', options); }); @@ -314,7 +310,7 @@ var switchMenu = document.createElement('div'); container.appendChild(switchMenu); function switchHandler(menu, name, on, off) { - if (localStorage[name] === 'on') { + if (options[name] === 'on') { on(); menu.classList.add('checked'); } From 2f0d46825a64b0e46082a31ef4c5da03776fa134 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 1 Apr 2022 12:01:11 +0800 Subject: [PATCH 0539/1027] clean up --- RawMangaAssistant.user.js | 55 +++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index d31b00e..0b003b2 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -6,14 +6,12 @@ // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 -// @match *://mikaraw.com/* +// @match *://mangameta.com/* +// @match *://mangagohan.com/* // @match *://klmag.net/* // @match *://rawdevart.com/* -// @match *://manga1000.com/* -// @match *://manga1001.com/* // @match *://welovemanga.one/* -// @match *://mangameta.com/* -// @match *://mangagohan.com/* +// @match *://mikaraw.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.6.js#sha256-KJZqM++cM/ynXn4uSmC8eo0PfsXg8lFkZisk8U3zVLs= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= @@ -32,22 +30,23 @@ // @webRequest {"selector": "*.sharethis.com/*", "action": "cancel"} // @ hakaraw.com / rawdevart.com // @webRequest {"selector": "*.exdynsrv.com/*", "action": "cancel"} -// @ manga1000.com / manga1001.com / mikaraw.com +// @ mangameta.com / mikaraw.com // @webRequest {"selector": "*.realsrv.com/*", "action": "cancel"} +// @ mangameta.com / klmag.net +// @webRequest {"selector": "*.wpadmngr.com/*", "action": "cancel"} +// @ mangameta.com +// @webRequest {"selector": "*mickeysdim.com/*", "action": "cancel"} +// @webRequest {"selector": "*ea1f460c2e.ca65b1531c.com/*", "action": "cancel"} +// @ mangagohan.com +// @webRequest {"selector": "*b7om8bdayac6at.com/*", "action": "cancel"} +// @webRequest {"selector": "*ietyofedinj89yewtburgh.com/*", "action": "cancel"} // @ mikaraw.com // @webRequest {"selector": "*puturebraving.com/*", "action": "cancel"} // @webRequest {"selector": "*.4dsply.com/*", "action": "cancel"} // @ rawdevart.com // @webRequest {"selector": "*.vdo.ai/*", "action": "cancel"} -// @ manga1000.com / manga1001.com -// @webRequest {"selector": "*static.manga10000.com/popup1001.js*", "action": "cancel"} -// @webRequest {"selector": "*downysewersettle.com/*", "action": "cancel"} -// @webRequest {"selector": "*.exosrv.com/*", "action": "cancel"} -// @webRequest {"selector": "*.bidgear.com/*", "action": "cancel"} -// @ klmag.net -// @webRequest {"selector": "*.wpadmngr.com/*", "action": "cancel"} +// @ klmag.net // @webRequest {"selector": "*cynicaugural.com/*", "action": "cancel"} -// @ weloma.art / weloma.net / klmag.net // @webRequest {"selector": "*.pubfuture.com/*", "action": "cancel"} // ==/UserScript== @@ -135,12 +134,15 @@ var i18n = message[navigator.language] ?? message['en-US']; // Supported sites var manga = { - 'mikaraw.com': { + 'mangameta.com': { image: 'div.chapter-c > img', + title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, + shortcut: 'div.linkchap > a' + }, + 'mangagohan.com': { + image: 'div.page-break > img', lazyload: 'data-src', - title: [{reg: /^([^(])+/, sel: '#header-bot li:nth-child(2) a', attr: 'title', nl: 0}, {reg: /([^\s]+)$/, sel: '#header-bot li:nth-child(3) a', attr: 'title', nl: 0}], - shortcut: ['#prev_chap', '#next_chap'], - ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'] + title: {reg: /^(.+)\s\(Raw\s–\sFree\)\s-[^\d]+(\d+)/, sel: 'meta[property="og:title"]', attr: 'content', tl: 1, ch: 2} }, 'klmag.net': { image: 'img.chapter-img', @@ -154,29 +156,20 @@ var manga = { lazyload: 'data-src', title: {reg: /^Chapter\s([^\s]+)\s\|\s(.+)\sPage/, sel: '#img-container > div > img', attr: 'alt', tl: 2, ch: 1} }, - 'manga1000.com': { - image: 'img.aligncenter', - title: {reg: /^(.+)\s-\sRaw\s【第(.+)話】/, sel: 'img.aligncenter', attr: 'alt', tl: 1, ch: 2}, - shortcut: 'div.linkchap > a' - }, 'welovemanga.one': { image: 'img.chapter-img', lazyload: 'data-srcset', title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'] }, - 'mangameta.com': { + 'mikaraw.com': { image: 'div.chapter-c > img', - title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, - shortcut: 'div.linkchap > a' - }, - 'mangagohan.com': { - image: 'div.page-break > img', lazyload: 'data-src', - title: {reg: /^(.+)\s\(Raw\s–\sFree\)\s-[^\d]+(\d+)/, sel: 'meta[property="og:title"]', attr: 'content', tl: 1, ch: 2} + title: [{reg: /^([^(])+/, sel: '#header-bot li:nth-child(2) a', attr: 'title', nl: 0}, {reg: /([^\s]+)$/, sel: '#header-bot li:nth-child(3) a', attr: 'title', nl: 0}], + shortcut: ['#prev_chap', '#next_chap'], + ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'] } }; -manga['manga1001.com'] = manga['manga1000.com']; watching = manga[location.host]; function longDecimalNumber(input, length = 3) { From 201671dcedd2e03841f227ad8fedc808235a2dd8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 1 Apr 2022 12:40:34 +0800 Subject: [PATCH 0540/1027] minor update --- NyaaTorrentHelper.user.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index aa11a27..a6fa849 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -56,12 +56,12 @@ css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin #filter-list > * > *:nth-child(3):not(text) {background-color: #0056b0;}\ #filter-list > * > *:nth-child(4) {background-color: #056b00;}\ #filter-list > * > *:nth-child(5) {background-color: #0005cc;}\ -#filter-preview {position: absolute; z-index: 3213; max-height: 800px; width: auto;}'; +#filter-preview {position: fixed; z-index: 3213; max-height: 800px; width: auto;}'; document.head.appendChild(css); var menu = document.createElement('div'); menu.id = 'filter-menu'; -menu.innerHTML = ''; +menu.innerHTML = ''; document.querySelector('#navbar').appendChild(menu); menu.querySelector('input').addEventListener('keypress', event => event.key === 'Enter' && menu.querySelector('button').click()); menu.querySelector('button').addEventListener('click', event => { @@ -108,8 +108,8 @@ function getFilterResult(data) { document.querySelectorAll('table > tbody > tr').forEach((element) => { var a = element.querySelectorAll('td:nth-child(2) > a'); a = a.length === 2 ? a[1] : a[0]; - var id = a.href.split('/').pop(); - var name = a.innerHTML; + var id = a.href.slice(a.href.lastIndexOf('/') + 1); + var name = a.innerText; var src = a.href; var size = element.querySelector('td:nth-child(4)').innerText; var link = element.querySelectorAll('td:nth-child(3) > a'); @@ -133,7 +133,8 @@ async function getPreviewHandler(data, mouse) { action[data.id] = true; data.type === 'none' ? alert(data.name + '\nNo Preview!') : data.type === 'image' ? createPreview(data.url, mouse) : - data.type === 'host' ? GM_openInTab(data.url, true) : await xmlNodeHandler(data.src).then(({type, url}) => { + data.type === 'host' ? GM_openInTab(data.url, true) : + await xmlNodeHandler(data.src).then(({type, url}) => { data.type = type; data.url = url; action[data.id] = false; From 6666a335c1d8b653c62273aa0214fe1682a2ba4f Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 1 Apr 2022 14:05:52 +0800 Subject: [PATCH 0541/1027] 6.17 --- RawMangaAssistant.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 0b003b2..520ea3b 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.16 +// @version 6.17 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -13,7 +13,7 @@ // @match *://welovemanga.one/* // @match *://mikaraw.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.6.js#sha256-KJZqM++cM/ynXn4uSmC8eo0PfsXg8lFkZisk8U3zVLs= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.7.js#sha256-Ac56C1xOZL1/1MNdakqJGU3hW0+CbxWIJR1wn8WayFo= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_getValue // @grant GM_setValue @@ -60,7 +60,7 @@ var images; var watching; var options = GM_getValue('options', {contextmenu: 'on'}); var {jsonrpc = 'http://localhost:6800/jsonrpc', secret = '', iconTop = 350, iconLeft = 200} = options; -var aria2 = new Aria2(localStorage.jsonrpc ?? 'http://localhost:6800/jsonrpc', localStorage.secret ?? ''); +var aria2 = new Aria2(jsonrpc, secret); var folder; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; From 5b46944530762ce768bc6cd9549816821ebe153f Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 2 Apr 2022 09:41:44 +0800 Subject: [PATCH 0542/1027] add support and fixed shortcut --- RawMangaAssistant.user.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 520ea3b..77244d2 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.17 +// @version 6.18 // @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) // @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 // @author jc3213 @@ -12,6 +12,7 @@ // @match *://rawdevart.com/* // @match *://welovemanga.one/* // @match *://mikaraw.com/* +// @match *://4uview.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.7.js#sha256-Ac56C1xOZL1/1MNdakqJGU3hW0+CbxWIJR1wn8WayFo= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= @@ -36,7 +37,8 @@ // @webRequest {"selector": "*.wpadmngr.com/*", "action": "cancel"} // @ mangameta.com // @webRequest {"selector": "*mickeysdim.com/*", "action": "cancel"} -// @webRequest {"selector": "*ea1f460c2e.ca65b1531c.com/*", "action": "cancel"} +// @webRequest {"selector": "*.ca65b1531c.com/*", "action": "cancel"} +// @webRequest {"selector": "*.592eb4ef33.com/*", "action": "cancel"} // @ mangagohan.com // @webRequest {"selector": "*b7om8bdayac6at.com/*", "action": "cancel"} // @webRequest {"selector": "*ietyofedinj89yewtburgh.com/*", "action": "cancel"} @@ -137,7 +139,7 @@ var manga = { 'mangameta.com': { image: 'div.chapter-c > img', title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, - shortcut: 'div.linkchap > a' + shortcut: ['a#prev_chap', 'a#next_chap'] }, 'mangagohan.com': { image: 'div.page-break > img', @@ -168,6 +170,11 @@ var manga = { title: [{reg: /^([^(])+/, sel: '#header-bot li:nth-child(2) a', attr: 'title', nl: 0}, {reg: /([^\s]+)$/, sel: '#header-bot li:nth-child(3) a', attr: 'title', nl: 0}], shortcut: ['#prev_chap', '#next_chap'], ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'] + }, + '4uview.com': { + image: 'img.chapter-img', + title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, + shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'] } }; watching = manga[location.host]; From 9b95f4f51da8ec9d188cb8721775c282e28d134d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 3 Apr 2022 19:31:58 +0800 Subject: [PATCH 0543/1027] Update RawMangaAssistant.user.js --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 77244d2..e2a7cfd 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -14,7 +14,7 @@ // @match *://mikaraw.com/* // @match *://4uview.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.2.7.js#sha256-Ac56C1xOZL1/1MNdakqJGU3hW0+CbxWIJR1wn8WayFo= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.8.js#sha256-KwVLV5qt8DpHLL6YkOe+aWMFb92cWtTVuc9ccbT7xTM= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_getValue // @grant GM_setValue From 13b005b9e65ccc0e610b2fdbb7c2cbc7df5eb74c Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 3 Apr 2022 21:10:42 +0800 Subject: [PATCH 0544/1027] v6.19 --- RawMangaAssistant.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index e2a7cfd..355aa61 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,9 +2,9 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.18 -// @description Assistant for raw manga online (LMangaToro, HakaRaw and etc.) -// @description:zh 漫画生肉网站 (MangaToro, HakaRaw 等) 助手脚本 +// @version 6.19 +// @description Assistant for raw manga online website +// @description:zh 漫画生肉网站助手脚本 // @author jc3213 // @match *://mangameta.com/* // @match *://mangagohan.com/* @@ -14,7 +14,7 @@ // @match *://mikaraw.com/* // @match *://4uview.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.8.js#sha256-KwVLV5qt8DpHLL6YkOe+aWMFb92cWtTVuc9ccbT7xTM= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.10.js#sha256-BMZovADoJ6OKcNrw1YxIG4iKLGT6tSEYinNfA+aN0qg= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_getValue // @grant GM_setValue From f56923e6dbd633b49e2610d5f3bc926249c835c1 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 13 Apr 2022 12:52:20 +0800 Subject: [PATCH 0545/1027] update --- RawMangaAssistant.user.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 355aa61..1b4eb1c 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,12 +2,12 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.19 +// @version 6.20 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 // @match *://mangameta.com/* -// @match *://mangagohan.com/* +// @match *://gokumanga.com/* // @match *://klmag.net/* // @match *://rawdevart.com/* // @match *://welovemanga.one/* @@ -39,7 +39,7 @@ // @webRequest {"selector": "*mickeysdim.com/*", "action": "cancel"} // @webRequest {"selector": "*.ca65b1531c.com/*", "action": "cancel"} // @webRequest {"selector": "*.592eb4ef33.com/*", "action": "cancel"} -// @ mangagohan.com +// @ gokumanga.com // @webRequest {"selector": "*b7om8bdayac6at.com/*", "action": "cancel"} // @webRequest {"selector": "*ietyofedinj89yewtburgh.com/*", "action": "cancel"} // @ mikaraw.com @@ -141,10 +141,10 @@ var manga = { title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, shortcut: ['a#prev_chap', 'a#next_chap'] }, - 'mangagohan.com': { + 'gokumanga.com': { image: 'div.page-break > img', lazyload: 'data-src', - title: {reg: /^(.+)\s\(Raw\s–\sFree\)\s-[^\d]+(\d+)/, sel: 'meta[property="og:title"]', attr: 'content', tl: 1, ch: 2} + title: {reg: /^(.+)\s-\s\u7b2c(.+)\u8a71/, sel: 'meta[property="og:title"]', attr: 'content', tl: 1, ch: 2} }, 'klmag.net': { image: 'img.chapter-img', @@ -191,8 +191,10 @@ function extractMangaTitle(title = '') { watching.title.forEach(item => { title += symbol + watching.title[0].reg.exec(document.querySelector(watching.title[0].sel).getAttribute(watching.title[0].attr))[watching.title[0].nl]; }); } else { - var result = watching.title.reg.exec(document.querySelector(watching.title.sel).getAttribute(watching.title.attr)); - title += symbol + result[watching.title.tl] + symbol + result[watching.title.ch]; + var text = document.querySelector(watching.title.sel).getAttribute(watching.title.attr); + var temp = watching.title.reg.exec(text); + console.log(text, temp) + title += symbol + temp[watching.title.tl] + symbol + temp[watching.title.ch]; } return title.replace(/[:\?\"\']/g, '_'); } From 20aee36e757544a866b498f61ca5c7d37d8b736a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 17 Jun 2022 19:46:27 +0800 Subject: [PATCH 0546/1027] update side support --- RawMangaAssistant.user.js | 63 +++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 1b4eb1c..a9b1ed7 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,17 +2,18 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.20 +// @version 6.22 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 // @match *://mangameta.com/* -// @match *://gokumanga.com/* -// @match *://klmag.net/* +// @match *://mangagohan.me/* +// @match *://klmanga.net/* // @match *://rawdevart.com/* -// @match *://welovemanga.one/* +// @match *://weloma.art/* // @match *://mikaraw.com/* -// @match *://4uview.com/* +// @match *://ney5.xyz/* +// @match *://mangahatachi.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.10.js#sha256-BMZovADoJ6OKcNrw1YxIG4iKLGT6tSEYinNfA+aN0qg= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= @@ -33,23 +34,25 @@ // @webRequest {"selector": "*.exdynsrv.com/*", "action": "cancel"} // @ mangameta.com / mikaraw.com // @webRequest {"selector": "*.realsrv.com/*", "action": "cancel"} -// @ mangameta.com / klmag.net +// @ mangameta.com / klmanga.net // @webRequest {"selector": "*.wpadmngr.com/*", "action": "cancel"} // @ mangameta.com -// @webRequest {"selector": "*mickeysdim.com/*", "action": "cancel"} -// @webRequest {"selector": "*.ca65b1531c.com/*", "action": "cancel"} -// @webRequest {"selector": "*.592eb4ef33.com/*", "action": "cancel"} -// @ gokumanga.com +// @webRequest {"selector": "*.com/*/47871", "action": "cancel"} +// @webRequest {"selector": "*.com/*/51016", "action": "cancel"} +// @ mangagohan.me // @webRequest {"selector": "*b7om8bdayac6at.com/*", "action": "cancel"} // @webRequest {"selector": "*ietyofedinj89yewtburgh.com/*", "action": "cancel"} // @ mikaraw.com // @webRequest {"selector": "*puturebraving.com/*", "action": "cancel"} // @webRequest {"selector": "*.4dsply.com/*", "action": "cancel"} +// @webRequest {"selector": "*begasuthy.com/*", "action": "cancel"} +// @webRequest {"selector": "*twazzyoidwlfe.com/*", "action": "cancel"} // @ rawdevart.com // @webRequest {"selector": "*.vdo.ai/*", "action": "cancel"} -// @ klmag.net -// @webRequest {"selector": "*cynicaugural.com/*", "action": "cancel"} -// @webRequest {"selector": "*.pubfuture.com/*", "action": "cancel"} +// @ klmanga.net +// @webRequest {"selector": "*.com/*50133", "action": "cancel"} +// @ mangahatachi.com +// @webRequest {"selector": "*sinmgaepu3or9a61w.com/*", "action": "cancel"} // ==/UserScript== 'use strict'; @@ -141,12 +144,12 @@ var manga = { title: {reg: /^(.+)(!?\s-\sRAW\s-)\sChapter\s([^\s]+)/, sel: 'a.chapter-title', attr: 'title', tl: 1, ch: 3}, shortcut: ['a#prev_chap', 'a#next_chap'] }, - 'gokumanga.com': { + 'mangagohan.me': { image: 'div.page-break > img', lazyload: 'data-src', title: {reg: /^(.+)\s-\s\u7b2c(.+)\u8a71/, sel: 'meta[property="og:title"]', attr: 'content', tl: 1, ch: 2} }, - 'klmag.net': { + 'klmanga.net': { image: 'img.chapter-img', lazyload: 'data-aload', title: {reg: /^(.+)\sChapter\s([^\s]+)/, sel: 'li.current > a', attr: 'title', tl: 1, ch: 2}, @@ -158,7 +161,7 @@ var manga = { lazyload: 'data-src', title: {reg: /^Chapter\s([^\s]+)\s\|\s(.+)\sPage/, sel: '#img-container > div > img', attr: 'alt', tl: 2, ch: 1} }, - 'welovemanga.one': { + 'weloma.art': { image: 'img.chapter-img', lazyload: 'data-srcset', title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, @@ -171,7 +174,10 @@ var manga = { shortcut: ['#prev_chap', '#next_chap'], ads: ['div[style*="z-index: 300000;"]', 'div[style*="float: left;"]'] }, - '4uview.com': { + 'mangahatachi.com': { + image: 'div.page-break > img', + }, + 'ney5.xyz': { image: 'img.chapter-img', title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'] @@ -186,17 +192,22 @@ function longDecimalNumber(input, length = 3) { } function extractMangaTitle(title = '') { - var symbol = navigator.platform === 'Win32' ? '\\' : '/'; - if (Array.isArray(watching.title)) { - watching.title.forEach(item => { title += symbol + watching.title[0].reg.exec(document.querySelector(watching.title[0].sel).getAttribute(watching.title[0].attr))[watching.title[0].nl]; }); + try { + var symbol = navigator.platform === 'Win32' ? '\\' : '/'; + if (Array.isArray(watching.title)) { + watching.title.forEach(item => { title += symbol + watching.title[0].reg.exec(document.querySelector(watching.title[0].sel).getAttribute(watching.title[0].attr))[watching.title[0].nl]; }); + } + else { + var text = document.querySelector(watching.title.sel).getAttribute(watching.title.attr); + var temp = watching.title.reg.exec(text); + console.log(text, temp) + title += symbol + temp[watching.title.tl] + symbol + temp[watching.title.ch]; + } + return title.replace(/[:\?\"\']/g, '_'); } - else { - var text = document.querySelector(watching.title.sel).getAttribute(watching.title.attr); - var temp = watching.title.reg.exec(text); - console.log(text, temp) - title += symbol + temp[watching.title.tl] + symbol + temp[watching.title.ch]; + catch (error) { + return; } - return title.replace(/[:\?\"\']/g, '_'); } // Create UI From c1d8018c63af373f8c494d662961a5f9f48ab0d8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 23 Jun 2022 10:14:27 +0800 Subject: [PATCH 0547/1027] support shortkey --- NyaaTorrentHelper.user.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index a6fa849..9837947 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 5.4 +// @version 5.5 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -46,7 +46,7 @@ if (['502 Bad Gateway', '429 Too Many Requests'].includes(document.title)) { var css= document.createElement('style'); css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin-top: 8px;}\ #filter-menu button {background-color: #056b00; margin-top: -3px;}\ -#filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; display: none; overflow-x: hidden; z-index: 3213;}\ +#filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; overflow-x: hidden; z-index: 3213;}\ #filter-list > * {display: grid; grid-template-columns: 700px 70px 70px 70px 70px; position: relative;}\ #filter-list > * > * {padding: 10px 5px; margin: 1px; color: #fff; border-radius: 5px; text-decoration: none;}\ #filter-list > * > *:not(:first-child, text) {text-align: center; cursor: pointer; user-select: none;}\ @@ -65,24 +65,40 @@ menu.innerHTML = ' '; + td.querySelector('#remove').addEventListener('click', event => tr.remove()); + tr.appendChild(td); }); // Preview handler From 918cf0f8751a23c944c33ad83a54e5b00e108885 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 27 Jun 2022 16:24:06 +0800 Subject: [PATCH 0549/1027] changed filter logic --- NyaaTorrentHelper.user.js | 129 ++++++++++++++------------------------ 1 file changed, 48 insertions(+), 81 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index d466e87..d7ca63e 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 6.0 +// @version 7.0 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -12,8 +12,9 @@ 'use strict'; // Variables -var keyword; var queue = []; +var keyword = ''; +var filter = []; var action = {}; // i18n Strings @@ -41,23 +42,44 @@ if (['502 Bad Gateway', '429 Too Many Requests'].includes(document.title)) { setTimeout(() => location.reload(), 5000); } +// Extract data +document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { + var a = tr.querySelectorAll('td:nth-child(2) > a'); + a = a.length === 2 ? a[1] : a[0]; + var id = a.href.slice(a.href.lastIndexOf('/') + 1); + var name = a.innerText; + var src = a.href; + var size = tr.querySelector('td:nth-child(4)').innerText; + var link = tr.querySelectorAll('td:nth-child(3) > a'); + var torrent = link.length === 2 ? link[0].href : null; + var magnet = link.length === 2 ? link[1].href : link[0].href; + magnet = magnet.slice(0, magnet.indexOf('&')); + var data = {id, name, src, size, torrent, magnet, tr}; + queue.push(data); + a.addEventListener('contextmenu', async event => { + event.preventDefault(); + await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); + a.style.cssText = 'color: #C33;'; + }); + var td = document.createElement('td'); + td.id = 'filter-extra'; + td.innerHTML = ' '; + td.querySelector('#remove').addEventListener('click', event => tr.remove()); + tr.appendChild(td); +}); + +// Helper Button +var new_th = document.createElement('th'); +new_th.innerText = 'Helper'; +new_th.className = 'text-center'; +document.querySelector('table > thead > tr').appendChild(new_th); + // Create UI var css= document.createElement('style'); css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin-top: 8px;}\ #filter-menu button {background-color: #056b00; margin-top: -3px;}\ #filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ -#filter-extra #remove {background-color: #000;}\ -#filter-list {position: absolute; background-color: #dff0d8; width: 1000px; height: 560px; white-space: nowrap; overflow-y: scroll; overflow-x: hidden; z-index: 3213;}\ -#filter-list > * {display: grid; grid-template-columns: 700px 70px 70px 70px 70px; position: relative;}\ -#filter-list > * > * {padding: 10px 5px; margin: 1px; color: #fff; border-radius: 5px; text-decoration: none;}\ -#filter-list > * > *:not(:first-child, text) {text-align: center; cursor: pointer; user-select: none;}\ -#filter-list > * > *:nth-child(1) {background-color: #2bceec; overflow: hidden; z-index: 3213;}\ -#filter-list > * > *:nth-child(1):hover {min-width: fit-content;}\ -#filter-list > * > *:nth-child(2) {background-color: #ee1c1c;}\ -#filter-list > * > *:nth-child(3):not(text) {background-color: #0056b0;}\ -#filter-list > * > *:nth-child(4) {background-color: #056b00;}\ -#filter-list > * > *:nth-child(5) {background-color: #0005cc;}\ -#filter-preview {position: fixed; z-index: 3213; max-height: 800px; width: auto;}'; +#filter-extra #remove {background-color: #000;}'; document.head.appendChild(css); var menu = document.createElement('div'); @@ -76,20 +98,21 @@ menu.querySelector('button').addEventListener('click', event => { return navigator.clipboard.writeText(result); } var value = menu.querySelector('input').value; - if (keyword !== value) { - popup.innerHTML = ''; - popup.style.cssText = 'left: ' + (document.documentElement.offsetWidth - 1000) / 2 + 'px; top: ' + document.querySelector('#navbar').offsetHeight + 'px;'; + if (filter.length !== 0) { + filter.forEach(tr => { tr.style.display = tr.style.display === 'none' ? 'table-row' : 'none'; }); + } + else if (keyword !== value) { var keys = value.split(/[\|\/\\\+,:;\s]+/); - queue.forEach(data => keys.filter(key => data.name.includes(key)).length === keys.length && getFilterResult(data) ); - keyword = value; + filter = []; + queue.forEach(data => { + if (keys.filter(key => data.name.includes(key)).length === keys.length) { + data.tr.style.display = 'none'; + filter.push(data.tr); + } + }); } - popup.style.display = popup.style.display === 'none' ? 'block' : 'none'; -}); -var popup = document.createElement('div'); -popup.id = 'filter-list'; -popup.style.display = 'none'; -document.body.appendChild(popup); +}); document.addEventListener('keydown', event => { if (event.key === 'ArrowRight') { @@ -100,66 +123,10 @@ document.addEventListener('keydown', event => { } }); -new MutationObserver(mutations => { - popup.style.display = 'none'; -}).observe(document.querySelector('form.navbar-form > div'), {subtree: true, attributes: true}); - -// Show filter result -function getFilterResult(data) { - var menu = document.createElement('div'); - menu.innerHTML = '' + data.name + '\ - ' + i18n.preview + '' + - (data.torrent ? '' + i18n.torrent + '' : '') + - '' + i18n.magnet + '\ - ' + i18n.copy + ''; - popup.appendChild(menu); - menu.querySelector('#preview').addEventListener('click', async event => { - await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); - event.target.style.cssText = 'background-color: #C3C;'; - }); - menu.querySelector('#copy').addEventListener('click', async event => { - event.target.innerText = '!'; - data = {...data, ...(!data.type && await xmlNodeHandler(data.src))}; - navigator.clipboard.writeText(parseTorrentInfo(data)); - event.target.innerText = i18n.copy; - }); -} - function parseTorrentInfo(data) { return i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.url ?? '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet; } -// Extract data -var new_th = document.createElement('th'); -new_th.innerText = 'Helper'; -new_th.className = 'text-center'; -document.querySelector('table > thead > tr').appendChild(new_th); - -document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { - var a = tr.querySelectorAll('td:nth-child(2) > a'); - a = a.length === 2 ? a[1] : a[0]; - var id = a.href.slice(a.href.lastIndexOf('/') + 1); - var name = a.innerText; - var src = a.href; - var size = tr.querySelector('td:nth-child(4)').innerText; - var link = tr.querySelectorAll('td:nth-child(3) > a'); - var torrent = link.length === 2 ? link[0].href : null; - var magnet = link.length === 2 ? link[1].href : link[0].href; - magnet = magnet.slice(0, magnet.indexOf('&')); - var data = {id, name, src, size, torrent, magnet}; - queue.push(data); - a.addEventListener('contextmenu', async event => { - event.preventDefault(); - await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); - a.style.cssText = 'color: #C33;'; - }); - var td = document.createElement('td'); - td.id = 'filter-extra'; - td.innerHTML = ' '; - td.querySelector('#remove').addEventListener('click', event => tr.remove()); - tr.appendChild(td); -}); - // Preview handler async function getPreviewHandler(data, mouse) { if (action[data.id] || document.getElementById('preview-' + data.id)) { From fc1d3513706299eb937cc9d1958e49527a1bc262 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 27 Jun 2022 17:02:25 +0800 Subject: [PATCH 0550/1027] update --- NyaaTorrentHelper.user.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index d7ca63e..e8124ec 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -58,12 +58,14 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { queue.push(data); a.addEventListener('contextmenu', async event => { event.preventDefault(); + td.querySelector('#load').style.display = 'inline'; await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); a.style.cssText = 'color: #C33;'; + td.querySelector('#load').style.display = 'none'; }); var td = document.createElement('td'); - td.id = 'filter-extra'; - td.innerHTML = ' '; + td.className = 'filter-extra'; + td.innerHTML = ' '; td.querySelector('#remove').addEventListener('click', event => tr.remove()); tr.appendChild(td); }); @@ -76,15 +78,17 @@ document.querySelector('table > thead > tr').appendChild(new_th); // Create UI var css= document.createElement('style'); -css.innerHTML = '#filter-menu input {display: inline-block; width: 170px; margin-top: 8px;}\ -#filter-menu button {background-color: #056b00; margin-top: -3px;}\ -#filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ -#filter-extra #remove {background-color: #000;}'; +css.innerHTML = '.filter-text {display: inline-block; width: 170px !important; margin-top: 8px;}\ +.filter-button {background-color: #056b00; margin-top: -3px;}\ +.filter-extra {position: relative;}\ +.filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ +.filter-extra #remove {background-color: #000;}\ +.filter-extra #load {position: absolute; right: 0px; top: 10px; display: none;}\ +.filter-preview {position: fixed; z-index: 3213; max-height: 800px; width: auto;}'; document.head.appendChild(css); var menu = document.createElement('div'); -menu.id = 'filter-menu'; -menu.innerHTML = ''; +menu.innerHTML = ''; document.querySelector('#navbar').appendChild(menu); menu.querySelector('input').addEventListener('keypress', event => event.key === 'Enter' && menu.querySelector('button').click()); menu.querySelector('button').addEventListener('click', event => { @@ -111,7 +115,6 @@ menu.querySelector('button').addEventListener('click', event => { } }); } - }); document.addEventListener('keydown', event => { @@ -129,12 +132,12 @@ function parseTorrentInfo(data) { // Preview handler async function getPreviewHandler(data, mouse) { - if (action[data.id] || document.getElementById('preview-' + data.id)) { + if (action[data.id] || document.getElementById(data.id)) { return; } action[data.id] = true; data.type === 'none' ? alert(data.name + '\nNo Preview!') : - data.type === 'image' ? createPreview(data.url, mouse) : + data.type === 'image' ? createPreview(data, mouse) : data.type === 'host' ? GM_openInTab(data.url, true) : await xmlNodeHandler(data.src).then(({type, url}) => { data.type = type; @@ -168,9 +171,10 @@ function xmlNodeHandler(url) { } // Create preview -function createPreview(url, mouse) { +function createPreview({id, url}, mouse) { var image = document.createElement('img'); - image.id = 'filter-preview'; + image.className = 'filter-preview'; + image.id = id; image.src = url; image.style.cssText = 'top: ' + (mouse.top + 800 > innerHeight ? innerHeight - 800 : mouse.top) + 'px; left: ' + (mouse.left + 600 > innerWidth ? innerWidth - 600 : mouse.left) + 'px;'; image.addEventListener('click', event => image.remove()); From 4ce1bce5024e78c75ef240869c8ee27dd7c4f235 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 27 Jun 2022 17:30:57 +0800 Subject: [PATCH 0551/1027] update logic --- NyaaTorrentHelper.user.js | 49 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index e8124ec..a19f6c8 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -54,20 +54,20 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { var torrent = link.length === 2 ? link[0].href : null; var magnet = link.length === 2 ? link[1].href : link[0].href; magnet = magnet.slice(0, magnet.indexOf('&')); - var data = {id, name, src, size, torrent, magnet, tr}; + var td = document.createElement('td'); + td.className = 'filter-extra'; + td.innerHTML = ' '; + td.querySelector('[type="button"]').addEventListener('click', event => tr.remove()); + tr.appendChild(td); + var data = {id, name, src, size, torrent, magnet, tr, td}; queue.push(data); a.addEventListener('contextmenu', async event => { event.preventDefault(); - td.querySelector('#load').style.display = 'inline'; + td.querySelector('span').style.display = 'inline'; await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); a.style.cssText = 'color: #C33;'; - td.querySelector('#load').style.display = 'none'; + td.querySelector('span').style.display = 'none'; }); - var td = document.createElement('td'); - td.className = 'filter-extra'; - td.innerHTML = ' '; - td.querySelector('#remove').addEventListener('click', event => tr.remove()); - tr.appendChild(td); }); // Helper Button @@ -82,8 +82,8 @@ css.innerHTML = '.filter-text {display: inline-block; width: 170px !important; m .filter-button {background-color: #056b00; margin-top: -3px;}\ .filter-extra {position: relative;}\ .filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ -.filter-extra #remove {background-color: #000;}\ -.filter-extra #load {position: absolute; right: 0px; top: 10px; display: none;}\ +.filter-extra [type="button"] {background-color: #000;}\ +.filter-extra span {position: absolute; right: 0px; top: 10px; display: none;}\ .filter-preview {position: fixed; z-index: 3213; max-height: 800px; width: auto;}'; document.head.appendChild(css); @@ -94,26 +94,31 @@ menu.querySelector('input').addEventListener('keypress', event => event.key === menu.querySelector('button').addEventListener('click', event => { if (event.ctrlKey) { var result = ''; - document.querySelectorAll('table > tbody > tr > td > #batch').forEach(async (batch, index) => { - if (batch.checked) { - result += parseTorrentInfo(queue[index]) + '\n\n=======================================================\n\n'; - } + document.querySelectorAll('table > tbody > tr > td > [type="checkbox"]:checked').forEach(batch => { + result += parseTorrentInfo(queue[batch.value]) + '\n\n=======================================================\n\n'; }); return navigator.clipboard.writeText(result); } var value = menu.querySelector('input').value; - if (filter.length !== 0) { + if (keyword === value) { + if (keyword === '') { + return; + } filter.forEach(tr => { tr.style.display = tr.style.display === 'none' ? 'table-row' : 'none'; }); } + else if (value === '') { + filter.forEach(tr => { tr.style.display = 'table-row'; }); + } else if (keyword !== value) { var keys = value.split(/[\|\/\\\+,:;\s]+/); filter = []; - queue.forEach(data => { - if (keys.filter(key => data.name.includes(key)).length === keys.length) { - data.tr.style.display = 'none'; - filter.push(data.tr); + queue.forEach(({name, tr}) => { + if (keys.filter(key => name.includes(key)).length === keys.length) { + tr.style.display = 'none'; + filter.push(tr); } }); + keyword = value; } }); @@ -126,8 +131,8 @@ document.addEventListener('keydown', event => { } }); -function parseTorrentInfo(data) { - return i18n.name + ':\n' + data.name + ' (' + data.size + ')\n\n' + i18n.preview + ':\n' + (data.url ?? '') + '\n\n' + (data.torrent ? i18n.torrent + ':\n' + data.torrent + '\n\n' : '') + i18n.magnet + ':\n' + data.magnet; +function parseTorrentInfo({name, size, url, torrent, magnet}) { + return i18n.name + ':\n' + name + ' (' + size + ')\n\n' + i18n.preview + ':\n' + (url ?? '') + '\n\n' + (torrent ? i18n.torrent + ':\n' + torrent + '\n\n' : '') + i18n.magnet + ':\n' + magnet; } // Preview handler @@ -176,7 +181,7 @@ function createPreview({id, url}, mouse) { image.className = 'filter-preview'; image.id = id; image.src = url; - image.style.cssText = 'top: ' + (mouse.top + 800 > innerHeight ? innerHeight - 800 : mouse.top) + 'px; left: ' + (mouse.left + 600 > innerWidth ? innerWidth - 600 : mouse.left) + 'px;'; + image.style.cssText = 'top: ' + mouse.top + 'px; left: ' + mouse.left + 'px;'; image.addEventListener('click', event => image.remove()); document.body.appendChild(image); } From 2e29a4d924bc6d9da78c8c1e9acec4af9086c961 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 27 Jun 2022 19:33:47 +0800 Subject: [PATCH 0552/1027] better logic --- NyaaTorrentHelper.user.js | 92 ++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index a19f6c8..256e75d 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -60,13 +60,18 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { td.querySelector('[type="button"]').addEventListener('click', event => tr.remove()); tr.appendChild(td); var data = {id, name, src, size, torrent, magnet, tr, td}; - queue.push(data); + queue[index] = data; a.addEventListener('contextmenu', async event => { event.preventDefault(); - td.querySelector('span').style.display = 'inline'; - await getPreviewHandler(data, {top: event.clientY, left: event.clientX}); + if (action[id] || document.getElementById(id)) { + return; + } + if (!data.type) { + var result = await fetchPreview(data); + queue[index] = data = {...data, ...result}; + } + getPreview(data, {top: event.clientY, left: event.clientX}); a.style.cssText = 'color: #C33;'; - td.querySelector('span').style.display = 'none'; }); }); @@ -93,24 +98,38 @@ document.querySelector('#navbar').appendChild(menu); menu.querySelector('input').addEventListener('keypress', event => event.key === 'Enter' && menu.querySelector('button').click()); menu.querySelector('button').addEventListener('click', event => { if (event.ctrlKey) { - var result = ''; - document.querySelectorAll('table > tbody > tr > td > [type="checkbox"]:checked').forEach(batch => { - result += parseTorrentInfo(queue[batch.value]) + '\n\n=======================================================\n\n'; - }); - return navigator.clipboard.writeText(result); + batchCopy(); + } + else { + filterResult(); } - var value = menu.querySelector('input').value; - if (keyword === value) { +}); + +function batchCopy() { + var text = ''; + return document.querySelectorAll('table > tbody > tr > td > [type="checkbox"]:checked').forEach(async batch => { + var data = queue[batch.value]; + if (!data.type) { + var result = await fetchPreview(data); + queue[batch.value] = data = {...data, ...result}; + } + navigator.clipboard.writeText(text += parseTorrentInfo(data) + '\n\n=======================================================\n\n'); + }); +} + +function filterResult() { + var text = menu.querySelector('input').value; + if (keyword === text) { if (keyword === '') { return; } filter.forEach(tr => { tr.style.display = tr.style.display === 'none' ? 'table-row' : 'none'; }); } - else if (value === '') { + else if (text === '') { filter.forEach(tr => { tr.style.display = 'table-row'; }); } - else if (keyword !== value) { - var keys = value.split(/[\|\/\\\+,:;\s]+/); + else if (keyword !== text) { + var keys = text.split(/[\|\/\\\+,:;\s]+/); filter = []; queue.forEach(({name, tr}) => { if (keys.filter(key => name.includes(key)).length === keys.length) { @@ -118,9 +137,9 @@ menu.querySelector('button').addEventListener('click', event => { filter.push(tr); } }); - keyword = value; + keyword = text; } -}); +} document.addEventListener('keydown', event => { if (event.key === 'ArrowRight') { @@ -136,29 +155,16 @@ function parseTorrentInfo({name, size, url, torrent, magnet}) { } // Preview handler -async function getPreviewHandler(data, mouse) { - if (action[data.id] || document.getElementById(data.id)) { - return; - } - action[data.id] = true; - data.type === 'none' ? alert(data.name + '\nNo Preview!') : - data.type === 'image' ? createPreview(data, mouse) : - data.type === 'host' ? GM_openInTab(data.url, true) : - await xmlNodeHandler(data.src).then(({type, url}) => { - data.type = type; - data.url = url; - action[data.id] = false; - getPreviewHandler(data, mouse); - }).catch(error => { action[data.id] = getPreviewHandler(data, mouse); }); - action[data.id] = false; -} - -function xmlNodeHandler(url) { - return fetch(url).then(response => response.text()).then(text => { +function fetchPreview({id, src, td}) { + action[id] = true; + td.querySelector('span').style.display = 'inline'; + return fetch(src).then(response => response.text()).then(text => { if (text.includes('502 Bad Gateway')) { throw new Error('502 Bad Gateway'); } else { + action[id] = false; + td.querySelector('span').style.display = 'none'; var node = document.createElement('div'); node.innerHTML = text; var desc = node.querySelector('#torrent-description').innerText; @@ -172,11 +178,25 @@ function xmlNodeHandler(url) { } return {type: 'none'}; } + }).catch(error => retryFetch(src)); +} + +function retryFetch(url) { + return new Promise(resolve => { + setTimeout(() => { + resolve(fetchPreview(url)); + }, 5000); }); } // Create preview -function createPreview({id, url}, mouse) { +function getPreview(data, mouse) { + data.type === 'none' ? alert(data.name + '\nNo Preview!') : + data.type === 'image' ? imagePreview(data, mouse) : + data.type === 'host' ? GM_openInTab(data.url, true) : null; +} + +function imagePreview(id, url, mouse) { var image = document.createElement('img'); image.className = 'filter-preview'; image.id = id; From bb518b0d09793f29f3da3edea8416c90a00f1d5e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 27 Jun 2022 19:35:11 +0800 Subject: [PATCH 0553/1027] update --- NyaaTorrentHelper.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 256e75d..a39ba02 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -113,10 +113,14 @@ function batchCopy() { var result = await fetchPreview(data); queue[batch.value] = data = {...data, ...result}; } - navigator.clipboard.writeText(text += parseTorrentInfo(data) + '\n\n=======================================================\n\n'); + navigator.clipboard.writeText(text += copyInfo(data) + '\n\n=======================================================\n\n'); }); } +function copyInfo({name, size, url, torrent, magnet}) { + return i18n.name + ':\n' + name + ' (' + size + ')\n\n' + i18n.preview + ':\n' + (url ?? '') + '\n\n' + (torrent ? i18n.torrent + ':\n' + torrent + '\n\n' : '') + i18n.magnet + ':\n' + magnet; +} + function filterResult() { var text = menu.querySelector('input').value; if (keyword === text) { @@ -150,10 +154,6 @@ document.addEventListener('keydown', event => { } }); -function parseTorrentInfo({name, size, url, torrent, magnet}) { - return i18n.name + ':\n' + name + ' (' + size + ')\n\n' + i18n.preview + ':\n' + (url ?? '') + '\n\n' + (torrent ? i18n.torrent + ':\n' + torrent + '\n\n' : '') + i18n.magnet + ':\n' + magnet; -} - // Preview handler function fetchPreview({id, src, td}) { action[id] = true; From 100c14d840462abadabf6ade6f2ea7507dd09629 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 28 Jun 2022 07:11:21 +0800 Subject: [PATCH 0554/1027] fixed logic --- NyaaTorrentHelper.user.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index a39ba02..1d0afc5 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -106,15 +106,27 @@ menu.querySelector('button').addEventListener('click', event => { }); function batchCopy() { - var text = ''; - return document.querySelectorAll('table > tbody > tr > td > [type="checkbox"]:checked').forEach(async batch => { + if (action.copy) { + return; + } + action.copy = true; + var array = []; + var checked = document.querySelectorAll('table > tbody > tr > td > [type="checkbox"]:checked'); + checked.forEach(async batch => { var data = queue[batch.value]; if (!data.type) { var result = await fetchPreview(data); queue[batch.value] = data = {...data, ...result}; } - navigator.clipboard.writeText(text += copyInfo(data) + '\n\n=======================================================\n\n'); + array.push(copyInfo(data)); }); + var interval = setInterval(() => { + if (checked.length === array.length) { + navigator.clipboard.writeText(array.join('\n\n======================================================\n\n')); + clearInterval(interval); + action.copy = false; + } + }, 500); } function copyInfo({name, size, url, torrent, magnet}) { From cf972477b4c1db1a81a4511f7625fb8d9a467e4b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 28 Jun 2022 07:25:06 +0800 Subject: [PATCH 0555/1027] fixed retryFetch --- NyaaTorrentHelper.user.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 1d0afc5..096d9ba 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -51,7 +51,7 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { var src = a.href; var size = tr.querySelector('td:nth-child(4)').innerText; var link = tr.querySelectorAll('td:nth-child(3) > a'); - var torrent = link.length === 2 ? link[0].href : null; + var torrent = link.length === 2 ? link[0].href : ''; var magnet = link.length === 2 ? link[1].href : link[0].href; magnet = magnet.slice(0, magnet.indexOf('&')); var td = document.createElement('td'); @@ -126,11 +126,11 @@ function batchCopy() { clearInterval(interval); action.copy = false; } - }, 500); + }, 250); } -function copyInfo({name, size, url, torrent, magnet}) { - return i18n.name + ':\n' + name + ' (' + size + ')\n\n' + i18n.preview + ':\n' + (url ?? '') + '\n\n' + (torrent ? i18n.torrent + ':\n' + torrent + '\n\n' : '') + i18n.magnet + ':\n' + magnet; +function copyInfo({name, size, url = '', torrent, magnet}) { + return i18n.name + ':\n' + name + ' (' + size + ')\n\n' + i18n.preview + ':\n' + url + '\n\n' + i18n.torrent + ':\n' + torrent + '\n\n' + i18n.magnet + ':\n' + magnet; } function filterResult() { @@ -171,8 +171,8 @@ function fetchPreview({id, src, td}) { action[id] = true; td.querySelector('span').style.display = 'inline'; return fetch(src).then(response => response.text()).then(text => { - if (text.includes('502 Bad Gateway')) { - throw new Error('502 Bad Gateway'); + if (text.includes('502 Bad Gateway') || text.includes('404 Not Found')) { + throw 'Error'; } else { action[id] = false; @@ -190,15 +190,11 @@ function fetchPreview({id, src, td}) { } return {type: 'none'}; } - }).catch(error => retryFetch(src)); -} - -function retryFetch(url) { - return new Promise(resolve => { + }).catch(error => new Promise(resolve => { setTimeout(() => { - resolve(fetchPreview(url)); + resolve(fetchPreview({id, src, td})); }, 5000); - }); + })); } // Create preview From 8c78aadfbaf12c2763a76802cc6880e6e1e645b7 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 28 Jun 2022 09:19:44 +0800 Subject: [PATCH 0556/1027] fixed image preview --- NyaaTorrentHelper.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 096d9ba..511cded 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -88,7 +88,7 @@ css.innerHTML = '.filter-text {display: inline-block; width: 170px !important; m .filter-extra {position: relative;}\ .filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ .filter-extra [type="button"] {background-color: #000;}\ -.filter-extra span {position: absolute; right: 0px; top: 10px; display: none;}\ +.filter-extra span {position: absolute; right: 3px; top: 10px; display: none;}\ .filter-preview {position: fixed; z-index: 3213; max-height: 800px; width: auto;}'; document.head.appendChild(css); @@ -204,12 +204,12 @@ function getPreview(data, mouse) { data.type === 'host' ? GM_openInTab(data.url, true) : null; } -function imagePreview(id, url, mouse) { +function imagePreview({id, url}, {top, left}) { var image = document.createElement('img'); image.className = 'filter-preview'; image.id = id; image.src = url; - image.style.cssText = 'top: ' + mouse.top + 'px; left: ' + mouse.left + 'px;'; + image.style.cssText = 'top: ' + top + 'px; left: ' + left + 'px;'; image.addEventListener('click', event => image.remove()); document.body.appendChild(image); } From bd600146f94159e4fac6a527dc338fb73a9bd553 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 28 Jun 2022 09:33:59 +0800 Subject: [PATCH 0557/1027] fixed image preview position --- NyaaTorrentHelper.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 511cded..c4ee443 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -70,7 +70,7 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { var result = await fetchPreview(data); queue[index] = data = {...data, ...result}; } - getPreview(data, {top: event.clientY, left: event.clientX}); + getPreview(data, {top: event.pageY, left: event.pageX}); a.style.cssText = 'color: #C33;'; }); }); @@ -89,7 +89,7 @@ css.innerHTML = '.filter-text {display: inline-block; width: 170px !important; m .filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ .filter-extra [type="button"] {background-color: #000;}\ .filter-extra span {position: absolute; right: 3px; top: 10px; display: none;}\ -.filter-preview {position: fixed; z-index: 3213; max-height: 800px; width: auto;}'; +.filter-preview {position: absolute; z-index: 3213; max-height: 800px; width: auto;}'; document.head.appendChild(css); var menu = document.createElement('div'); From 89d250bf92221cc01a728d730344b01804d09209 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 1 Jul 2022 20:15:16 +0800 Subject: [PATCH 0558/1027] update --- RawMangaAssistant.user.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index a9b1ed7..588d495 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.22 +// @version 6.23 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -11,7 +11,7 @@ // @match *://klmanga.net/* // @match *://rawdevart.com/* // @match *://weloma.art/* -// @match *://mikaraw.com/* +// @match *://nikaraw.com/* // @match *://ney5.xyz/* // @match *://mangahatachi.com/* // @connect * @@ -42,7 +42,7 @@ // @ mangagohan.me // @webRequest {"selector": "*b7om8bdayac6at.com/*", "action": "cancel"} // @webRequest {"selector": "*ietyofedinj89yewtburgh.com/*", "action": "cancel"} -// @ mikaraw.com +// @ nikaraw.com // @webRequest {"selector": "*puturebraving.com/*", "action": "cancel"} // @webRequest {"selector": "*.4dsply.com/*", "action": "cancel"} // @webRequest {"selector": "*begasuthy.com/*", "action": "cancel"} @@ -51,6 +51,9 @@ // @webRequest {"selector": "*.vdo.ai/*", "action": "cancel"} // @ klmanga.net // @webRequest {"selector": "*.com/*50133", "action": "cancel"} +// @webRequest {"selector": "*educedsteeped.com/*", "action": "cancel"} +// @ weloma.art +// @webRequest {"selector": "*.com/*52076", "action": "cancel"} // @ mangahatachi.com // @webRequest {"selector": "*sinmgaepu3or9a61w.com/*", "action": "cancel"} // ==/UserScript== @@ -167,7 +170,7 @@ var manga = { title: {reg: /^(.+)(!?\s-\sRAW)?\sChapter\s([^\s]+)/, sel: 'img.chapter-img', attr: 'alt', tl: 1, ch: 3}, shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'] }, - 'mikaraw.com': { + 'nikaraw.com': { image: 'div.chapter-c > img', lazyload: 'data-src', title: [{reg: /^([^(])+/, sel: '#header-bot li:nth-child(2) a', attr: 'title', nl: 0}, {reg: /([^\s]+)$/, sel: '#header-bot li:nth-child(3) a', attr: 'title', nl: 0}], From 71827e581f71bb14c9b92e0218dfdb60a9102749 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 2 Jul 2022 20:28:21 +0800 Subject: [PATCH 0559/1027] fix new filter result --- NyaaTorrentHelper.user.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index c4ee443..7b67920 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -148,10 +148,13 @@ function filterResult() { var keys = text.split(/[\|\/\\\+,:;\s]+/); filter = []; queue.forEach(({name, tr}) => { - if (keys.filter(key => name.includes(key)).length === keys.length) { + if (keys.filter(key => name.includes(key)).length !== keys.length) { tr.style.display = 'none'; filter.push(tr); } + else { + tr.style.display = 'table-row'; + } }); keyword = text; } From 7ae3b0a66cb828b7aa6d49a85b1600ca45b158fc Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 6 Jul 2022 21:19:41 +0800 Subject: [PATCH 0560/1027] update --- RawMangaAssistant.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 588d495..fe72779 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -30,9 +30,9 @@ // @webRequest {"selector": "*.disqus.com/*", "action": "cancel"} // @webRequest {"selector": "*.facebook.net/*", "action": "cancel"} // @webRequest {"selector": "*.sharethis.com/*", "action": "cancel"} -// @ hakaraw.com / rawdevart.com +// @ nakaraw.com / rawdevart.com // @webRequest {"selector": "*.exdynsrv.com/*", "action": "cancel"} -// @ mangameta.com / mikaraw.com +// @ mangameta.com / nikaraw.com // @webRequest {"selector": "*.realsrv.com/*", "action": "cancel"} // @ mangameta.com / klmanga.net // @webRequest {"selector": "*.wpadmngr.com/*", "action": "cancel"} @@ -157,7 +157,7 @@ var manga = { lazyload: 'data-aload', title: {reg: /^(.+)\sChapter\s([^\s]+)/, sel: 'li.current > a', attr: 'title', tl: 1, ch: 2}, shortcut: ['a.btn.btn-info.prev', 'a.btn.btn-info.next'], - ads: ['#id-custom_banner', 'div.float-ck'] + ads: ['center > a > img'] }, 'rawdevart.com': { image: '#img-container > div > img', From 8e54fd75a9574697b76937d9172d0ffaebd3cd52 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 7 Jul 2022 21:05:46 +0800 Subject: [PATCH 0561/1027] v7.1 --- NyaaTorrentHelper.user.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 7b67920..3c1f67f 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 7.0 +// @version 7.1 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -57,7 +57,15 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { var td = document.createElement('td'); td.className = 'filter-extra'; td.innerHTML = ' '; - td.querySelector('[type="button"]').addEventListener('click', event => tr.remove()); + td.querySelector('[type="button"]').addEventListener('click', async event => { + if (event.ctrlKey) { + data = await checkPreview(queue[index]); + navigator.clipboard.writeText(copyInfo(data)); + } + else { + tr.style.display = 'none'; + } + }); tr.appendChild(td); var data = {id, name, src, size, torrent, magnet, tr, td}; queue[index] = data; @@ -66,10 +74,7 @@ document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { if (action[id] || document.getElementById(id)) { return; } - if (!data.type) { - var result = await fetchPreview(data); - queue[index] = data = {...data, ...result}; - } + queue[index] = data = await checkPreview(data); getPreview(data, {top: event.pageY, left: event.pageX}); a.style.cssText = 'color: #C33;'; }); @@ -114,10 +119,7 @@ function batchCopy() { var checked = document.querySelectorAll('table > tbody > tr > td > [type="checkbox"]:checked'); checked.forEach(async batch => { var data = queue[batch.value]; - if (!data.type) { - var result = await fetchPreview(data); - queue[batch.value] = data = {...data, ...result}; - } + queue[batch.value] = data = await checkPreview(queue[batch.value]); array.push(copyInfo(data)); }); var interval = setInterval(() => { @@ -170,6 +172,14 @@ document.addEventListener('keydown', event => { }); // Preview handler +async function checkPreview(data) { + if (!data.type) { + var result = await fetchPreview(data); + data = {...data, ...result}; + } + return data; +} + function fetchPreview({id, src, td}) { action[id] = true; td.querySelector('span').style.display = 'inline'; From 2451995e1f8b75ca2ca0d235ede30110d3301fde Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 9 Jul 2022 13:34:25 +0800 Subject: [PATCH 0562/1027] update for new ui --- SpeedRunHelper.user.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 33662cf..5abd83d 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,19 +1,21 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.2 +// @version 3.3 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} +// @webRequest {"selector": "*.stripe.com/*", "action": "cancel"} // @webRequest {"selector": "*.scorecardresearch.com/*", "action": "cancel"} // ==/UserScript== 'use strict'; var logger = {}; var style = {}; +var board = document.querySelector('#leaderboarddiv'); var css = document.createElement('style'); css.innerHTML = '#widget {display: none !important;}\ @@ -35,10 +37,12 @@ css.innerHTML = '#widget {display: none !important;}\ .speedrun-minimum #speedrun-restore:nth-child(2), .speedrun-maximum #speedrun-restore:nth-child(4) {display: inline-block;}'; document.body.append(css); -document.getElementById('leaderboarddiv').addEventListener('contextmenu', event => { - event.preventDefault(); - var row = [...document.querySelectorAll('tr')].find(record => record.contains(event.target)); +document.querySelector('.widget-column').remove(); + +board.addEventListener('contextmenu', event => { + var row = [...board.querySelectorAll('tbody > tr')].find(record => record.contains(event.target)); if (row) { + event.preventDefault(); var src = row.getAttribute('data-target'); if (src) { var id = src.slice(src.lastIndexOf('/') + 1); @@ -63,7 +67,7 @@ function viewSpeedrunRecord(id, title, src) { fetch(src).then(response => response.text()).then(htmlText => { var xml = document.createElement('div'); xml.innerHTML = htmlText; - logger[id] = xml.querySelector('#centerwidget iframe') ?? xml.querySelector('#centerwidget a[rel="noopener"]'); + logger[id] = xml.querySelector('iframe[class]'); createRecordWindow(id, title, logger[id]); xml.remove(); }); From f1f958bdd4cf76771fad42405452292a40355c8d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 15 Jul 2022 07:47:46 +0800 Subject: [PATCH 0563/1027] better logic and ui creation --- BilibiliVideoDownloader.user.js | 46 +++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 91ae7b5..ddec2c8 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.6 +// @version 3.7 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -10,6 +10,7 @@ // ==/UserScript== var {autowide = '0', videocodec = '0'} = localStorage; +var [widescreen, toolbar] = location.pathname.startsWith('/video/') ? ['div.bilibili-player-video-btn-widescreen', '#arc_toolbar_report'] : ['div.squirtle-video-widescreen', '#toolbar_module']; var title; var video; var worker; @@ -33,11 +34,13 @@ var format = { }; var css = document.createElement('style'); -css.innerHTML = '#helper-main {background-color: #fff; position: relative; z-index: 9999; display: inline-block; user-select: none;}\ -#helper-options, #helper-analyse {position: relative; border: 1px solid #000; padding: 5px;}\ +css.innerHTML = '#helper-main {position: relative; z-index: 9999; display: inline-block; user-select: none;}\ +#helper-options, #helper-analyse {position: absolute; border: 1px solid #000; padding: 5px; top: 40px; left: 0px; background-color: #fff;}\ +#helper-options {width: 115px;}\ #helper-options p, #helper-options select, .helper-button {font-size: 16px; text-align: center; padding: 5px;}\ #helper-options p, #helper-options option:checked {color: #c26; font-weight: bold;}\ #helper-options select {width: 100%;}\ +#helper-analyse {width: 400px;}\ #helper-analyse ul {display: inline-block; margin-righ: 3px; vertical-align: top;}\ #helper-analyse a {display: inline-block; width: 100px;}\ .helper-button {background-color: #c26; color: #fff; height: 16px; line-height: 16px; padding: 10px 15px; display: inline-block; margin: 0px 3px 3px 0px; cursor: pointer;}\ @@ -64,6 +67,7 @@ menu.querySelector('#analyse').addEventListener('click', async event => { } analyse.style.display = analyse.style.display === 'none' ? 'block' : 'none'; }); + var options = document.createElement('div'); options.id = 'helper-options'; options.innerHTML = '

                          自动宽屏

                          \ @@ -73,9 +77,11 @@ options.querySelector('#videocodec').value = videocodec; options.addEventListener('change', event => { localStorage[event.target.id] = event.target.value; }); + var analyse = document.createElement('div'); analyse.id = 'helper-analyse'; menu.append(options, analyse, css); + options.style.display = analyse.style.display = 'none'; new MutationObserver(mutations => { @@ -88,8 +94,8 @@ new MutationObserver(mutations => { }).observe(document.head, {childList: true, subtree: true}); setTimeout(() => { - var toolbar = document.querySelector('#arc_toolbar_report') ?? document.querySelector('#toolbar_module'); - toolbar.append(menu, css); + var bar = document.querySelector(toolbar); + bar.append(menu, css); }, 2000); function biliVideoTitle(name) { @@ -99,7 +105,7 @@ function biliVideoTitle(name) { function biliVideoAutoWide() { var observer = setInterval(() => { - var wide = document.querySelector('div.bilibili-player-video-btn-widescreen') ?? document.querySelector('div.squirtle-video-widescreen'); + var wide = document.querySelector(widescreen); if (wide) { clearInterval(observer); if (wide.classList.contains('closed') || wide.classList.contains('active') || autowide === '0' ) { @@ -111,23 +117,25 @@ function biliVideoAutoWide() { } function biliVideoThumbnail(url) { - var menu = createMenuitem('视频封面', url, url.slice(url.lastIndexOf('.'))); - analyse.querySelector('#helper-thumb').appendChild(menu); + var top = document.createElement('ul'); + var sub = createMenuitem('视频封面', url, url.slice(url.lastIndexOf('.'))); + top.append(sub); + analyse.append(top); } async function biliVideoExtractor(param, key) { - var menu = {av1: [], hevc: [], avc: [], aac: []}; - await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}).then(response => response.json()).then(({[key]: {dash: {video, audio}}}) => { - [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { - var codec = codecs.slice(0, codecs.indexOf('.')); - var array = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av1' ? menu.av1 : menu.aac; - var {label, ext} = format[id]; - array.push(createMenuitem(label, baseUrl, '.' + codec + ext, codec)); - }); + var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; + var response = await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}); + var {[key]: {dash: {video, audio}}} = await response.json(); + [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { + var codec = codecs.slice(0, codecs.indexOf('.')); + var top = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av1' ? menu.av1 : menu.aac; + var {label, ext} = format[id]; + var sub = createMenuitem(label, baseUrl, '.' + codec + ext, codec); + top.appendChild(sub); }); - var video = videocodec === '2' && menu.av1.length !== 0 ? menu.av1 : videocodec === '1' && menu.hevc.length !== 0 ? menu.hevc : menu.avc; - video.forEach(item => document.querySelector('#helper-video').appendChild(item)); - menu.aac.forEach(item => document.querySelector('#helper-audio').appendChild(item)); + var codec = videocodec === '2' && menu.av1.length !== 0 ? menu.av1 : videocodec === '1' && menu.hevc.length !== 0 ? menu.hevc : menu.avc; + analyse.append(codec, menu.aac) } function createMenuitem(label, url, ext, codec) { From 0919695f20bb107bb93ef6311d9a63715e26fc04 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 15 Jul 2022 08:11:44 +0800 Subject: [PATCH 0564/1027] 7.2 --- NyaaTorrentHelper.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 3c1f67f..0d76f00 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 7.1 +// @version 7.2 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -90,7 +90,7 @@ document.querySelector('table > thead > tr').appendChild(new_th); var css= document.createElement('style'); css.innerHTML = '.filter-text {display: inline-block; width: 170px !important; margin-top: 8px;}\ .filter-button {background-color: #056b00; margin-top: -3px;}\ -.filter-extra {position: relative;}\ +.filter-extra {position: relative; width: 75px !important;}\ .filter-extra * {margin: 0px 3px; width: 16px; height: 16px;}\ .filter-extra [type="button"] {background-color: #000;}\ .filter-extra span {position: absolute; right: 3px; top: 10px; display: none;}\ From 12c7fd6ca10723cb600730fe5bd659d86f038296 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 15 Jul 2022 10:12:58 +0800 Subject: [PATCH 0565/1027] better performance --- NyaaTorrentHelper.user.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 0d76f00..46f77d3 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -190,9 +190,8 @@ function fetchPreview({id, src, td}) { else { action[id] = false; td.querySelector('span').style.display = 'none'; - var node = document.createElement('div'); - node.innerHTML = text; - var desc = node.querySelector('#torrent-description').innerText; + var temp = text.slice(text.indexOf('"torrent-description"') + 22); + var desc = temp.slice(0, temp.indexOf('
                          ')); var img = /https?:\/\/[^\)\]]+\.(jpg|png)/g.exec(desc); if (img) { return {type: 'image', url: img[0]}; From 9e732bdf8796d01d501968b303204e03ed11d4ad Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 27 Jul 2022 12:43:57 +0800 Subject: [PATCH 0566/1027] v3.4 support new website style --- SpeedRunHelper.user.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 5abd83d..7586153 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.3 +// @version 3.4 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -15,7 +15,7 @@ 'use strict'; var logger = {}; var style = {}; -var board = document.querySelector('#leaderboarddiv'); +var board = document.querySelector('div[component-name="LatestLeaderboardWidget"]'); var css = document.createElement('style'); css.innerHTML = '#widget {display: none !important;}\ @@ -39,18 +39,19 @@ document.body.append(css); document.querySelector('.widget-column').remove(); -board.addEventListener('contextmenu', event => { - var row = [...board.querySelectorAll('tbody > tr')].find(record => record.contains(event.target)); - if (row) { - event.preventDefault(); - var src = row.getAttribute('data-target'); - if (src) { - var id = src.slice(src.lastIndexOf('/') + 1); - var cells = row.querySelectorAll('td'); - var record = row.classList.contains('center-sm') ? {rank: 1, time: 2} : row.classList.contains('height-minimal') ? {rank: 1, player: 2, time: 3} : {rank: 0, player: 1, time: 2}; - var player = record.player ? cells[record.player].innerText : document.querySelector('.profile-username').innerText; - var title = '
                          Rank : ' + cells[record.rank].innerHTML + ' Player : ' + player + ' Time : ' + cells[record.time].innerHTML + ''; - viewSpeedrunRecord(id, title, src); +board.addEventListener('click', event => { + if (event.ctrlKey) { + var record = [...board.querySelectorAll('a.rounded-sm')].find(record => record.contains(event.target)); + if (record) { + event.preventDefault(); + var src = record.href; + if (src) { + var id = src.slice(src.lastIndexOf('/') + 1); + var game = record.parentNode.querySelector('div.font-title').innerText; + var [style, category, rank, time, player, nation] = record.innerText.split('\n'); + var title = '
                          Rank : ' + rank + ' Player : ' + player + ' Time : ' + time + ''; + viewSpeedrunRecord(id, title, src); + } } } }); From 2c510f4c88e0994563f8dd0b529d3bfc34882670 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 27 Jul 2022 15:41:04 +0800 Subject: [PATCH 0567/1027] v3.5, mixed code --- SpeedRunHelper.user.js | 48 ++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 7586153..fae5cba 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.4 +// @version 3.5 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* @@ -15,7 +15,6 @@ 'use strict'; var logger = {}; var style = {}; -var board = document.querySelector('div[component-name="LatestLeaderboardWidget"]'); var css = document.createElement('style'); css.innerHTML = '#widget {display: none !important;}\ @@ -39,24 +38,37 @@ document.body.append(css); document.querySelector('.widget-column').remove(); -board.addEventListener('click', event => { - if (event.ctrlKey) { - var record = [...board.querySelectorAll('a.rounded-sm')].find(record => record.contains(event.target)); - if (record) { - event.preventDefault(); - var src = record.href; - if (src) { - var id = src.slice(src.lastIndexOf('/') + 1); - var game = record.parentNode.querySelector('div.font-title').innerText; - var [style, category, rank, time, player, nation] = record.innerText.split('\n'); - var title = '
                          Rank : ' + rank + ' Player : ' + player + ' Time : ' + time + ''; - viewSpeedrunRecord(id, title, src); - } +if (document.title.includes('series') || document.title.startsWith('Runs')) { + appendEvent('div.maincontent', 'a.rounded-sm', record => { + var src = record.href; + var game = record.parentNode.querySelector('div.font-title').innerText; + var [style, category, rank, time, player, nation] = record.innerText.split('\n'); + viewSpeedrunRecord(src, rank, player, time); + }); +} +else { + appendEvent('#leaderboarddiv', 'tbody > tr', record => { + var src = record.getAttribute('data-target'); + var [rank, player, time, platform, date] = record.innerText.split('\t'); + rank = rank === '' ? record.childNodes[0].innerHTML : rank; + viewSpeedrunRecord(src, rank, player, time); + }); +} + +function appendEvent(board, record, callback) { + var _board_ = document.querySelector(board); + _board_.addEventListener('contextmenu', event => { + event.preventDefault(); + var _record_ = [..._board_.querySelectorAll(record)].find(record => record.contains(event.target)); + if (_record_) { + callback(_record_); } - } -}); + }); +} -function viewSpeedrunRecord(id, title, src) { +function viewSpeedrunRecord(src, rank, player, time) { + var id = src.slice(src.lastIndexOf('/') + 1); + var title = '
                          Rank : ' + rank + ' Player : ' + player + ' Time : ' + time + ''; var view = document.querySelector('#speedrun-' + id); if (view) { style[id] = view.style.cssText = 'top: ' + (130 + view.idx * 30) + 'px; left: ' + ((screen.availWidth - 1280) / 2 + view.idx * 30) + 'px;'; From 6c3d497921631bf787ec0d126330e898703dd92e Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 28 Jul 2022 17:05:57 +0800 Subject: [PATCH 0568/1027] v7.3 fixed shortcut --- NyaaTorrentHelper.user.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/NyaaTorrentHelper.user.js b/NyaaTorrentHelper.user.js index 46f77d3..e4cd248 100644 --- a/NyaaTorrentHelper.user.js +++ b/NyaaTorrentHelper.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Nyaa Torrent Helper // @namespace https://github.com/jc3213/userscript -// @version 7.2 +// @version 7.3 // @description Nyaa Torrent right click to open available open preview in new tab // @author jc3213 // @connect * @@ -42,6 +42,16 @@ if (['502 Bad Gateway', '429 Too Many Requests'].includes(document.title)) { setTimeout(() => location.reload(), 5000); } +// Shortcut +document.addEventListener('keydown', event => { + if (event.key === 'ArrowLeft') { + document.querySelector('ul.pagination > li:first-child > a').click(); + } + if (event.key === 'ArrowRight') { + document.querySelector('ul.pagination > li:last-child > a').click(); + } +}); + // Extract data document.querySelectorAll('table > tbody > tr').forEach((tr, index) => { var a = tr.querySelectorAll('td:nth-child(2) > a'); @@ -162,15 +172,6 @@ function filterResult() { } } -document.addEventListener('keydown', event => { - if (event.key === 'ArrowRight') { - document.querySelector('li.next > a').click(); - } - else if (event.key === 'ArrowLeft') { - document.querySelector('li.previous > a').click(); - } -}); - // Preview handler async function checkPreview(data) { if (!data.type) { From ef663db137a73e873df4dc7f0ac756177b8e0fe6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 5 Aug 2022 19:30:09 +0800 Subject: [PATCH 0569/1027] fixed extraction --- BilibiliVideoDownloader.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index ddec2c8..de51be1 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.7 +// @version 3.8 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -59,8 +59,8 @@ menu.querySelector('#analyse').addEventListener('click', async event => { worker = false; videocodec = localStorage.videocodec; analyse.innerHTML = '
                                '; - var {aid, cid, __INITIAL_STATE__: {videoData, elecFullInfo, h1Title, epInfo}} = document.defaultView; - var [title, thumb, playurl, key] = aid && cid ? [videoData.title, elecFullInfo.data.pic, 'x/player/playurl?avid=' + aid + '&cid=' + cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; + var {aid, bvid, videoData, elecFullInfo, h1Title, epInfo} = document.defaultView.__INITIAL_STATE__; + var [title, thumb, playurl, key] = bvid ? [videoData.title, elecFullInfo.pic, 'x/player/playurl?avid=' + videoData.aid + '&cid=' + videoData.cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; biliVideoTitle(title); biliVideoThumbnail(thumb); await biliVideoExtractor(playurl, key); @@ -125,7 +125,7 @@ function biliVideoThumbnail(url) { async function biliVideoExtractor(param, key) { var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; - var response = await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}); + var response = await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=4048', {credentials: 'include'}); var {[key]: {dash: {video, audio}}} = await response.json(); [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); @@ -134,7 +134,7 @@ async function biliVideoExtractor(param, key) { var sub = createMenuitem(label, baseUrl, '.' + codec + ext, codec); top.appendChild(sub); }); - var codec = videocodec === '2' && menu.av1.length !== 0 ? menu.av1 : videocodec === '1' && menu.hevc.length !== 0 ? menu.hevc : menu.avc; + var codec = videocodec === '2' && menu.av1.childNodes.length !== 0 ? menu.av1 : videocodec === '1' && menu.hevc.childNodes.length !== 0 ? menu.hevc : menu.avc; analyse.append(codec, menu.aac) } From fa85b229ae9aa582c64feed33ad42c3acdd90bc8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 5 Aug 2022 23:15:38 +0800 Subject: [PATCH 0570/1027] add av1 codec support --- BilibiliVideoDownloader.user.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index de51be1..a67d1da 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.8 +// @version 3.9 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -30,6 +30,7 @@ var format = { '15': {label: '360P 流畅', ext: '.360LQ.mp4'}, 'avc1': '视频编码: H.264', 'hev1': '视频编码: HEVC', + 'av01': '视频编码:AV1', 'mp4a': '音频编码: AAC' }; @@ -129,7 +130,7 @@ async function biliVideoExtractor(param, key) { var {[key]: {dash: {video, audio}}} = await response.json(); [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); - var top = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av1' ? menu.av1 : menu.aac; + var top = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av01' ? menu.av1 : menu.aac; var {label, ext} = format[id]; var sub = createMenuitem(label, baseUrl, '.' + codec + ext, codec); top.appendChild(sub); From 7088a9e486ece202111b32ce44d27f5d565afe3f Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 6 Aug 2022 17:43:58 +0800 Subject: [PATCH 0571/1027] fixed auto wide --- BilibiliVideoDownloader.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index a67d1da..736f9db 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.9 +// @version 3.10 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -10,7 +10,7 @@ // ==/UserScript== var {autowide = '0', videocodec = '0'} = localStorage; -var [widescreen, toolbar] = location.pathname.startsWith('/video/') ? ['div.bilibili-player-video-btn-widescreen', '#arc_toolbar_report'] : ['div.squirtle-video-widescreen', '#toolbar_module']; +var [widescreen, widestate, toolbar] = location.pathname.startsWith('/video/') ? ['div.bpx-player-ctrl-wide', 'bpx-state-entered', '#arc_toolbar_report'] : ['div.squirtle-video-widescreen', 'active', '#toolbar_module']; var title; var video; var worker; @@ -109,7 +109,7 @@ function biliVideoAutoWide() { var wide = document.querySelector(widescreen); if (wide) { clearInterval(observer); - if (wide.classList.contains('closed') || wide.classList.contains('active') || autowide === '0' ) { + if (wide.classList.contains(widestate) || autowide === '0' ) { return; } wide.click(); From 7232bccc21379abb7afc3e2a9ea534214ae9eb81 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 6 Aug 2022 23:48:12 +0800 Subject: [PATCH 0572/1027] fixed 4k and 8k extraction, better codec priority --- BilibiliVideoDownloader.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 736f9db..03b1fcb 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.10 +// @version 3.11 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -126,7 +126,7 @@ function biliVideoThumbnail(url) { async function biliVideoExtractor(param, key) { var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; - var response = await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=4048', {credentials: 'include'}); + var response = await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}); var {[key]: {dash: {video, audio}}} = await response.json(); [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); @@ -135,7 +135,7 @@ async function biliVideoExtractor(param, key) { var sub = createMenuitem(label, baseUrl, '.' + codec + ext, codec); top.appendChild(sub); }); - var codec = videocodec === '2' && menu.av1.childNodes.length !== 0 ? menu.av1 : videocodec === '1' && menu.hevc.childNodes.length !== 0 ? menu.hevc : menu.avc; + var codec = videocodec === '2' ? menu.av1.childNodes.length !== 0 ? menu.av1 : menu.hevc.childNodes.length !== 0 ? menu.hevc : menu.avc : videocodec === '1' && menu.hevc.childNodes.length !== 0 ? menu.hevc : menu.avc; analyse.append(codec, menu.aac) } From b3a2c7550f716b6814113cdbb4c62ba21ca9cec8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 12 Aug 2022 17:13:05 +0800 Subject: [PATCH 0573/1027] v4.9: add download current pdf button --- NarouSyosetuManager.user.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 610ba8d..1b55f55 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 小説家になろう 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 4.8 +// @version 4.9 // @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* @@ -29,7 +29,7 @@ var scheduler = GM_getValue('scheduler', novelist.today); // UI作成関連 var css = document.createElement('style'); -css.innerHTML = '.manager-button {background-color: #fff; text-align: center; vertical-align: middle; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; display: inline-block; cursor: pointer; font-weight: bold;}\ +css.innerHTML = '.manager-button {background-color: #fff; text-align: center; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; cursor: pointer; font-weight: bold;}\ .manager-button:hover, .manager-shelf > *:not(:first-child) > *:hover {filter: opacity(75%);}\ .manager-button:active,.manager-shelf > *:not(:first-child) > *:active {filter: opacity(45%);}\ .manager-checked {padding: 4px; border: 2px inset #00F;}\ @@ -46,19 +46,23 @@ css.innerHTML = '.manager-button {background-color: #fff; text-align: center; ve .notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff;}'; document.head.appendChild(css); -var manager = document.createElement('span'); -manager.innerHTML = '書庫管理'; -manager.className = 'manager-button'; -manager.style.cssText = 'margin: 8px 5px;' -manager.addEventListener('click', event => { +var navi = document.querySelector('#head_nav'); +var navi_inner = navi.querySelector('li:last-child'); +var manager = document.createElement('div'); +manager.innerHTML = '書庫管理ダウンロード'; +manager.style.cssText = 'position: absolute; top: 15px; left: ' + (navi_inner.offsetLeft + navi_inner.offsetWidth) + 'px;'; +manager.querySelector('#manager').addEventListener('click', event => { if (!show) { bookmark.forEach(fancyTableItem); show = true; } - container.style.display = manager.classList.contains('manager-checked') ? 'none' : 'block'; - manager.classList.toggle('manager-checked'); + container.style.display = event.target.classList.contains('manager-checked') ? 'none' : 'block'; + event.target.classList.toggle('manager-checked'); +}); +manager.querySelector('#downpdf').addEventListener('click', event => { + batchDownloadPreHandler(novelist); }); -(document.getElementById('head_nav') ?? document.body).appendChild(manager); +(navi ?? document.body).appendChild(manager); var container = document.createElement('div'); container.innerHTML = '
                                NCODE登録\ From 875e9155bac3c54af85fea3bfc9454608daccfcf Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 14 Aug 2022 09:10:36 +0800 Subject: [PATCH 0574/1027] better download button --- NarouSyosetuManager.user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 1b55f55..e7f183b 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -49,7 +49,8 @@ document.head.appendChild(css); var navi = document.querySelector('#head_nav'); var navi_inner = navi.querySelector('li:last-child'); var manager = document.createElement('div'); -manager.innerHTML = '書庫管理ダウンロード'; +manager.innerHTML = '書庫管理\ +ダウンロード'; manager.style.cssText = 'position: absolute; top: 15px; left: ' + (navi_inner.offsetLeft + navi_inner.offsetWidth) + 'px;'; manager.querySelector('#manager').addEventListener('click', event => { if (!show) { @@ -60,6 +61,7 @@ manager.querySelector('#manager').addEventListener('click', event => { event.target.classList.toggle('manager-checked'); }); manager.querySelector('#downpdf').addEventListener('click', event => { + event.preventDefault(); batchDownloadPreHandler(novelist); }); (navi ?? document.body).appendChild(manager); From fa30eb723a1e5590cfc1ecd7dd099217d805d1b2 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 15 Aug 2022 19:02:14 +0800 Subject: [PATCH 0575/1027] add shortcut for next/previous videos --- BilibiliVideoDownloader.user.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 03b1fcb..a009153 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.11 +// @version 3.12 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -10,7 +10,7 @@ // ==/UserScript== var {autowide = '0', videocodec = '0'} = localStorage; -var [widescreen, widestate, toolbar] = location.pathname.startsWith('/video/') ? ['div.bpx-player-ctrl-wide', 'bpx-state-entered', '#arc_toolbar_report'] : ['div.squirtle-video-widescreen', 'active', '#toolbar_module']; +var [toolbar, widescreen, widestate, next, prev] = location.pathname.startsWith('/video/') ? ['#arc_toolbar_report', 'div.bpx-player-ctrl-wide', 'bpx-state-entered', 'div.bpx-player-ctrl-next', 'div.bpx-player-ctrl-prev'] : ['#toolbar_module', 'div.squirtle-video-widescreen', 'active', 'div.squirtle-video-next']; var title; var video; var worker; @@ -59,7 +59,7 @@ menu.querySelector('#analyse').addEventListener('click', async event => { if (worker || videocodec !== localStorage.videocodec) { worker = false; videocodec = localStorage.videocodec; - analyse.innerHTML = '
                                      '; + analyse.innerHTML = ''; var {aid, bvid, videoData, elecFullInfo, h1Title, epInfo} = document.defaultView.__INITIAL_STATE__; var [title, thumb, playurl, key] = bvid ? [videoData.title, elecFullInfo.pic, 'x/player/playurl?avid=' + videoData.aid + '&cid=' + videoData.cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; biliVideoTitle(title); @@ -69,6 +69,17 @@ menu.querySelector('#analyse').addEventListener('click', async event => { analyse.style.display = analyse.style.display === 'none' ? 'block' : 'none'; }); +document.addEventListener('keydown', event => { + if (event.ctrlKey) { + if (event.key === 'ArrowRight') { + document.querySelector(next).click(); + } + if (event.key === 'ArrowLeft') { + document.querySelector(prev).click(); + } + } +}); + var options = document.createElement('div'); options.id = 'helper-options'; options.innerHTML = '

                                      自动宽屏

                                      \ From 061a70fb796b788e084b5802a7d523d175df7334 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 17 Aug 2022 23:08:50 +0800 Subject: [PATCH 0576/1027] fixed extract av1 with high resolution --- BilibiliVideoDownloader.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index a009153..28706f0 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.12 +// @version 3.13 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -137,7 +137,7 @@ function biliVideoThumbnail(url) { async function biliVideoExtractor(param, key) { var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; - var response = await fetch('https://api.bilibili.com/' + param + '&fourk=1&fnval=2000', {credentials: 'include'}); + var response = await fetch('https://api.bilibili.com/' + param + '&fnval=4050', {credentials: 'include'}); var {[key]: {dash: {video, audio}}} = await response.json(); [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); From 19d32ec5af8d186ce944dfbc472e61de093af543 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Thu, 25 Aug 2022 21:55:26 +0800 Subject: [PATCH 0577/1027] minor update --- BilibiliVideoDownloader.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 28706f0..63ea8cf 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -138,7 +138,8 @@ function biliVideoThumbnail(url) { async function biliVideoExtractor(param, key) { var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; var response = await fetch('https://api.bilibili.com/' + param + '&fnval=4050', {credentials: 'include'}); - var {[key]: {dash: {video, audio}}} = await response.json(); + var json = await response.json(); + var {video, audio} = json[key].dash; [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); var top = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av01' ? menu.av1 : menu.aac; From 9ff7548552d87d1f51c90ffa2bc71577252785da Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 30 Aug 2022 16:40:58 +0800 Subject: [PATCH 0578/1027] update libs --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index fe72779..2abaebf 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -15,7 +15,7 @@ // @match *://ney5.xyz/* // @match *://mangahatachi.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.10.js#sha256-BMZovADoJ6OKcNrw1YxIG4iKLGT6tSEYinNfA+aN0qg= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_getValue // @grant GM_setValue From b80c0b14fd3ad6f6fea1ff6534c6ba0705609a35 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 11 Sep 2022 19:10:24 +0800 Subject: [PATCH 0579/1027] fixed thumb and extraction --- BilibiliVideoDownloader.user.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 63ea8cf..5ba3fcd 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,7 +2,7 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.13 +// @version 3.14 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 @@ -60,8 +60,8 @@ menu.querySelector('#analyse').addEventListener('click', async event => { worker = false; videocodec = localStorage.videocodec; analyse.innerHTML = ''; - var {aid, bvid, videoData, elecFullInfo, h1Title, epInfo} = document.defaultView.__INITIAL_STATE__; - var [title, thumb, playurl, key] = bvid ? [videoData.title, elecFullInfo.pic, 'x/player/playurl?avid=' + videoData.aid + '&cid=' + videoData.cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; + var {aid, bvid, videoData, h1Title, epInfo} = document.defaultView.__INITIAL_STATE__; + var [title, thumb, playurl, key] = bvid ? [videoData.title, videoData.pic, 'x/player/playurl?avid=' + videoData.aid + '&cid=' + videoData.cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; biliVideoTitle(title); biliVideoThumbnail(thumb); await biliVideoExtractor(playurl, key); @@ -135,9 +135,10 @@ function biliVideoThumbnail(url) { analyse.append(top); } -async function biliVideoExtractor(param, key) { +async function biliVideoExtractor(playurl, key) { +console.log('https://api.bilibili.com/' + playurl + '&fnval=4050'); var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; - var response = await fetch('https://api.bilibili.com/' + param + '&fnval=4050', {credentials: 'include'}); + var response = await fetch('https://api.bilibili.com/' + playurl + '&fnval=4050', {credentials: 'include'}); var json = await response.json(); var {video, audio} = json[key].dash; [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { From 3f22b3be7442de2c539ec631f8c7c1c62b0fcff3 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 11 Sep 2022 19:44:10 +0800 Subject: [PATCH 0580/1027] fixed thumbnail, better performance, support dwa2 --- BilibiliVideoDownloader.user.js | 63 +++++++++++++++++---------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 5ba3fcd..b55b3f6 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,11 +2,12 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.14 +// @version 3.16 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 // @match *://www.bilibili.com/video/* +// @run-at document-end // ==/UserScript== var {autowide = '0', videocodec = '0'} = localStorage; @@ -60,8 +61,8 @@ menu.querySelector('#analyse').addEventListener('click', async event => { worker = false; videocodec = localStorage.videocodec; analyse.innerHTML = ''; - var {aid, bvid, videoData, h1Title, epInfo} = document.defaultView.__INITIAL_STATE__; - var [title, thumb, playurl, key] = bvid ? [videoData.title, videoData.pic, 'x/player/playurl?avid=' + videoData.aid + '&cid=' + videoData.cid, 'data'] : [h1Title, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; + var {videoData, epInfo} = document.defaultView.__INITIAL_STATE__; + var [title, thumb, playurl, key] = videoData ? [videoData.title, videoData.pic, 'x/player/playurl?avid=' + videoData.aid + '&cid=' + videoData.cid, 'data'] : [epInfo.share_copy, epInfo.cover, 'pgc/player/web/playurl?ep_id=' + epInfo.id, 'result']; biliVideoTitle(title); biliVideoThumbnail(thumb); await biliVideoExtractor(playurl, key); @@ -96,41 +97,35 @@ menu.append(options, analyse, css); options.style.display = analyse.style.display = 'none'; -new MutationObserver(mutations => { - if (video !== location.pathname) { - video = location.pathname; - worker = true; - options.style.display = analyse.style.display = 'none'; - biliVideoAutoWide(); +var observer = setInterval(() => { + var playbar = document.querySelector(toolbar); + var widebtn = document.querySelector(widescreen); + if (widebtn) { + clearInterval(observer); + playbar.append(menu, css); + if (!widebtn.classList.contains(widestate) && autowide === '1' ) { + widebtn.click(); + } + new MutationObserver(mutations => { + if (video !== location.pathname) { + video = location.pathname; + worker = true; + options.style.display = analyse.style.display = 'none'; + } + }).observe(document.head, {childList: true, subtree: true}); } -}).observe(document.head, {childList: true, subtree: true}); - -setTimeout(() => { - var bar = document.querySelector(toolbar); - bar.append(menu, css); -}, 2000); +}, 200); function biliVideoTitle(name) { var multi = document.querySelector('#multi_page li.on > a'); - title = (name + (multi ? multi.innerText : '')).replace(/[\/\\\?\|\<\>:"']/g, ''); -} - -function biliVideoAutoWide() { - var observer = setInterval(() => { - var wide = document.querySelector(widescreen); - if (wide) { - clearInterval(observer); - if (wide.classList.contains(widestate) || autowide === '0' ) { - return; - } - wide.click(); - } - }, 500); + name = multi ? name + multi.innerText : name; + title = name.replace(/[\/\\\?\|\<\>:"']/g, ''); } function biliVideoThumbnail(url) { var top = document.createElement('ul'); - var sub = createMenuitem('视频封面', url, url.slice(url.lastIndexOf('.'))); + var fixed = url.replace(/^(https?:)?\/\//, 'https://') + var sub = createMenuitem('视频封面', fixed, url.slice(url.lastIndexOf('.'))); top.append(sub); analyse.append(top); } @@ -156,6 +151,12 @@ function createMenuitem(label, url, ext, codec) { var li = document.createElement('li'); var tip = codec === undefined ? '' : format[codec] ? format[codec] : '未知编码: ' + codec; li.innerHTML = '' + label + ''; - li.addEventListener('click', event => navigator.clipboard.writeText(title)); + li.addEventListener('click', event => { + if (event.ctrlKey) { + event.preventDefault(); + var aria2 = JSON.stringify({url, options: {out: title + ext, referer: location.href}}); + navigator.clipboard.writeText(aria2); + } + }); return li; } From d98e26396ade7a98b530358df565f3cb985f25a9 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 11 Sep 2022 19:52:53 +0800 Subject: [PATCH 0581/1027] clean up --- BilibiliVideoDownloader.user.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index b55b3f6..58bc3b1 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -98,23 +98,22 @@ menu.append(options, analyse, css); options.style.display = analyse.style.display = 'none'; var observer = setInterval(() => { - var playbar = document.querySelector(toolbar); var widebtn = document.querySelector(widescreen); if (widebtn) { clearInterval(observer); - playbar.append(menu, css); + document.querySelector(toolbar).append(menu, css); if (!widebtn.classList.contains(widestate) && autowide === '1' ) { widebtn.click(); } - new MutationObserver(mutations => { - if (video !== location.pathname) { - video = location.pathname; - worker = true; - options.style.display = analyse.style.display = 'none'; - } - }).observe(document.head, {childList: true, subtree: true}); } }, 200); +new MutationObserver(mutations => { + if (video !== location.pathname) { + video = location.pathname; + worker = true; + options.style.display = analyse.style.display = 'none'; + } +}).observe(document.head, {childList: true, subtree: true}); function biliVideoTitle(name) { var multi = document.querySelector('#multi_page li.on > a'); @@ -131,7 +130,6 @@ function biliVideoThumbnail(url) { } async function biliVideoExtractor(playurl, key) { -console.log('https://api.bilibili.com/' + playurl + '&fnval=4050'); var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; var response = await fetch('https://api.bilibili.com/' + playurl + '&fnval=4050', {credentials: 'include'}); var json = await response.json(); From d93bc49e1a1d72004fa2f0cb1786b07a858af8ee Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 11:21:04 +0800 Subject: [PATCH 0582/1027] use jsui/manager.js --- BilibiliLiveRoomFilter.user.js | 146 ++++++++++++++++----------------- 1 file changed, 69 insertions(+), 77 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 420ef9a..96802c3 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -7,6 +7,7 @@ // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* +// @require https://raw.githubusercontent.com/jc3213/jsui/main/manager_0.5.js#sha256-hC0vacAz75BeMQoLyj4/4tHKuh+ZOXWFUtdsVT75uHQ= // @grant GM_getValue // @grant GM_setValue // @noframes @@ -17,27 +18,19 @@ var banned = GM_getValue('banned', []); var show = false; var css = document.createElement('style'); -css.innerHTML = '.fancybox {background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ -.fancybox > * {width: 320px; height: 360px; overflow-y: auto; display: inline-block;}\ -.fancybox, .fancybox table {border: 1px solid #23ade5;}\ -.fancybox textarea {resize: none; height: calc(100% - 30px); width: 100%; font-size: 14px; padding: 3px; margin-bottom: 5px;}\ -.fancybox td, .fancybutton {padding: 5px 10px; text-align: center; font-size: 14px;}\ -.fancybox td:nth-child(1) {width: 120px;}\ -.fancybox td:nth-child(2) {width: 200px;}\ -.fancybox thead {background-color: #000; color: #fff;}\ -.fancybox tbody td:nth-child(2) {background-color: #eee;}\ +css.innerText = '.fancybox {background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ +.fancybutton {padding: 5px 10px; text-align: center; font-size: 14px;}\ .fancybutton {background-color: #23ade5; color: #ffffff; border-radius: 3px; user-select: none; cursor: pointer;}\ .fancybutton:hover {filter: opacity(60%);}\ .fancybutton:active {filter: opacity(30%);}\ -.fancybox .fancybutton {margin-left: 3px;}\ .fancymenu {display: none; margin-top: 10px;}\ .fancymenu * {display: inline-block; width: 38%; margin-left: 10px;}' document.head.appendChild(css); -var manager = document.createElement('span'); -manager.innerHTML = '管理屏蔽列表'; -manager.className = 'fancybutton'; -manager.addEventListener('click', event => { +var opener = document.createElement('span'); +opener.innerText = '管理屏蔽列表'; +opener.className = 'fancybutton'; +opener.addEventListener('click', event => { if (!show) { banned.forEach(({id, liver}) => makeBanlist(id, liver)); show = true; @@ -45,57 +38,63 @@ manager.addEventListener('click', event => { container.style.display =container.style.display === 'none' ? 'block' : 'none'; }); +var upload = document.createElement('input'); +upload.type = 'file'; +upload.accept = '.json'; +upload.addEventListener('change', event => { + if (confirm('确定要导入屏蔽列表【' + event.target.files[0].name.slice(0, -5) + '】吗?')) { + var reader = new FileReader(); + reader.readAsText(event.target.files[0]); + reader.onload = () => { + var list = JSON.parse(reader.result); + list.forEach(({id, liver}) => addBanlist(id, liver)); + saveBanlist(); + } + upload.value = ''; + } +}); + var container = document.createElement('div'); container.className = 'fancybox'; container.style.display = 'none'; -var batch_box = document.createElement('div'); -batch_box.innerHTML = '
                                      \ -批量屏蔽\ -导入列表\ -导出列表\ -清空列表
                                      '; -batch_box.addEventListener('click', event => { - if (event.target.id === 'bililive_filter_batch' && confirm('确定要屏蔽列表中的直播间吗?')) { - var batch = document.querySelector('textarea'); - batch.value.split('\n').forEach(item => { +var manager = new Manager({ + menu: [ + {label: '批量屏蔽', onclick: batchBlock}, + {label: '导入列表', onclick: importList}, + {label: '导出列表', onclick: exportList}, + {label: '清空列表', onclick: batchUnblock}, + ], + title: ['直播间ID', '主播昵称'] +}); +manager.parentNode = container; +function batchBlock(event) { + if (confirm('确定要屏蔽列表中的直播间吗?')) { + manager.entry.value.split('\n').forEach(item => { var rule = item.split(/[\\\/\s,.@#$^&]+/); if (!isNaN(rule[0])) { addBanlist(rule[0], rule[1]); } }); saveBanlist(); - batch.value = ''; + manager.entry.value = ''; } - if (event.target.id === 'bililive_filter_export' && confirm('确定要导出当前屏蔽列表吗?')) { +} +function exportList(event) { + if (confirm('确定要导出当前屏蔽列表吗?')) { blobToFile(new Blob([JSON.stringify(banned)], {type: 'application/json'}), 'bilibili直播间屏蔽列表'); } - if (event.target.id === 'bililive_filter_import') { - batch_box.querySelector('input').click(); - } - if (event.target.id === 'bililive_filter_clear' && confirm('确定要清空当前屏蔽列表吗?')) { - ban_list.querySelector('tbody').innerHTML = ''; +} +function importList(event) { + upload.querySelector('input').click(); +} +function batchUnblock(event) { + if (confirm('确定要清空当前屏蔽列表吗?')) { + manager.clear(); banned = []; saveBanlist(); } -}); -batch_box.addEventListener('change', event => { - if (confirm('确定要导入屏蔽列表【' + event.target.files[0].name.slice(0, -5) + '】吗?')) { - var reader = new FileReader(); - reader.readAsText(event.target.files[0]); - reader.onload = () => { - var list = JSON.parse(reader.result); - list.forEach(({id, liver}) => addBanlist(id, liver)); - saveBanlist(); - } - event.target.value = ''; - } -}); - -var ban_list = document.createElement('table'); -ban_list.innerHTML = '直播间主播'; - -container.append(batch_box, ban_list); +} var area = location.pathname.slice(1); if (area === '') { @@ -109,12 +108,7 @@ else if (area === 'all') { } else if (!isNaN(area)) { var player = document.querySelector('section.player-and-aside-area'); - if (player) { - banInsideLiveRoom(player, area); - } - else { - livePlayerInFrame(area); - } + player ? banInsideLiveRoom(player, area) : livePlayerInFrame(area); } else { console.log('尚未支持的特殊区间,请到NGA原帖或Github反馈'); @@ -134,7 +128,7 @@ function livePlayerInFrame(id) { function applyFilterToArea({menu, room, list}) { setTimeout(() => { - document.querySelector(menu).appendChild(manager); + document.querySelector(menu).appendChild(opener); document.querySelector(menu).after(container); container.style.top = document.querySelector(menu).offsetTop + 30 + 'px'; document.querySelectorAll(room).forEach(addMenuToLiveRoom); @@ -155,7 +149,7 @@ function banInsideLiveRoom(domPlayer, id) { var liver = domPlayer.querySelector('a.room-owner-username').innerText; var area = domPlayer.querySelector('a.area-link').href; var block = document.createElement('span'); - block.innerHTML = '屏蔽直播间'; + block.innerText = '屏蔽直播间'; block.className = 'fancybutton'; block.addEventListener('click', event => { if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { @@ -171,35 +165,33 @@ function banInsideLiveRoom(domPlayer, id) { } function makeBanlist(id, liver) { - var ban = document.createElement('tr'); - ban.id = 'banned_' + id; - ban.innerHTML = '' + id + '' + liver + ''; - ban.querySelector('.fancybutton').addEventListener('click', event => { - if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { - removeBanlist(id); - saveBanlist(); + console.log(id, liver); + manager.addNewColumn = { + cells: [id, liver], + onclick: event => removeBanList(event.target.parentNode, id, liver) + }; +} + +function removeBanList(column, id, liver) { + if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { + column.remove(); + var index = banned.findIndex(rule => rule.id === id); + if (index !== -1) { + banned.splice(index, 1); } - }); - ban_list.querySelector('tbody').appendChild(ban); + saveBanlist(); + } } function addBanlist(id, liver) { if (!banned.find(rule => rule.id === id)) { banned.push({id, liver}); - if (ban_list && show) { + if (show) { makeBanlist(id, liver); } } } -function removeBanlist(id) { - var index = banned.findIndex(rule => rule.id === id); - if (index !== -1) { - banned.splice(index, 1); - ban_list.querySelector('#banned_' + id).remove(); - } -} - function saveBanlist() { GM_setValue('banned', banned); document.querySelectorAll('div.index_3Uym8ODI').forEach(banLiveRoom); @@ -224,8 +216,8 @@ function addMenuToLiveRoom(element) { return; } var id = banLiveRoom(element); - var liver = element.querySelector('div.Item_QAOnosoB').innerText; - var name = element.querySelector('div.Item_2GEmdhg6').innerText; + var liver = element.querySelector('div.Item_QAOnosoB').innerText.trim(); + var name = element.querySelector('div.Item_2GEmdhg6').innerText.trim(); var preview = element.querySelector('div.Item_2n7ef9LN').style['background-image']; var url = 'https' + preview.slice(preview.indexOf(':'), preview.lastIndexOf('"')); From 2ffa93cd982da4c354c08294ef18aaec25f814f8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 11:27:00 +0800 Subject: [PATCH 0583/1027] v3.4 --- BilibiliLiveRoomFilter.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 96802c3..818ec17 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,7 +2,7 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 3.3 +// @version 3.4 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 From f2a9aa0af11b00ddcf51386fdad94cec8d3d95df Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 15:46:13 +0800 Subject: [PATCH 0584/1027] v3.5 update jsui/manager.js --- BilibiliLiveRoomFilter.user.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 818ec17..878e76e 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,12 +2,12 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 3.4 +// @version 3.5 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/manager_0.5.js#sha256-hC0vacAz75BeMQoLyj4/4tHKuh+ZOXWFUtdsVT75uHQ= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/manager_0.0.6.js#sha256-HhNRyn4DdiFhZ102HtT2SVXSsfzoWKzHxoZ4xAHJtfs= // @grant GM_getValue // @grant GM_setValue // @noframes @@ -58,15 +58,12 @@ var container = document.createElement('div'); container.className = 'fancybox'; container.style.display = 'none'; -var manager = new Manager({ - menu: [ - {label: '批量屏蔽', onclick: batchBlock}, - {label: '导入列表', onclick: importList}, - {label: '导出列表', onclick: exportList}, - {label: '清空列表', onclick: batchUnblock}, - ], - title: ['直播间ID', '主播昵称'] -}); +var manager = new Manager([ + {label: '批量屏蔽', onclick: batchBlock}, + {label: '导入列表', onclick: importList}, + {label: '导出列表', onclick: exportList}, + {label: '清空列表', onclick: batchUnblock}, +], ['直播间ID', '主播昵称']); manager.parentNode = container; function batchBlock(event) { if (confirm('确定要屏蔽列表中的直播间吗?')) { @@ -165,11 +162,16 @@ function banInsideLiveRoom(domPlayer, id) { } function makeBanlist(id, liver) { - console.log(id, liver); - manager.addNewColumn = { - cells: [id, liver], - onclick: event => removeBanList(event.target.parentNode, id, liver) - }; + manager.add([id, liver], event => { + if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { + event.target.parentNode.remove(); + var index = banned.findIndex(rule => rule.id === id); + if (index !== -1) { + banned.splice(index, 1); + } + saveBanlist(); + } + }); } function removeBanList(column, id, liver) { From 32d692f508e00670f6a02f5d2db22141be787f19 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 15:53:17 +0800 Subject: [PATCH 0585/1027] oops --- BilibiliLiveRoomFilter.user.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 878e76e..ae752d9 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -174,17 +174,6 @@ function makeBanlist(id, liver) { }); } -function removeBanList(column, id, liver) { - if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { - column.remove(); - var index = banned.findIndex(rule => rule.id === id); - if (index !== -1) { - banned.splice(index, 1); - } - saveBanlist(); - } -} - function addBanlist(id, liver) { if (!banned.find(rule => rule.id === id)) { banned.push({id, liver}); From a1d4124a3c6b976ce5e76c1387d116b0bd310e5c Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 17:11:16 +0800 Subject: [PATCH 0586/1027] better logic --- BilibiliLiveRoomFilter.user.js | 58 ++++++++++++++++------------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index ae752d9..943d638 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,12 +2,13 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 3.5 +// @version 3.6 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/manager_0.0.6.js#sha256-HhNRyn4DdiFhZ102HtT2SVXSsfzoWKzHxoZ4xAHJtfs= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/button.js +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/manager_0.0.6.js // @grant GM_getValue // @grant GM_setValue // @noframes @@ -17,20 +18,10 @@ var banned = GM_getValue('banned', []); var show = false; -var css = document.createElement('style'); -css.innerText = '.fancybox {background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ -.fancybutton {padding: 5px 10px; text-align: center; font-size: 14px;}\ -.fancybutton {background-color: #23ade5; color: #ffffff; border-radius: 3px; user-select: none; cursor: pointer;}\ -.fancybutton:hover {filter: opacity(60%);}\ -.fancybutton:active {filter: opacity(30%);}\ -.fancymenu {display: none; margin-top: 10px;}\ -.fancymenu * {display: inline-block; width: 38%; margin-left: 10px;}' -document.head.appendChild(css); +var btnMaker = new Button(); +btnMaker.cssText = '.jsui_button {background-color: #23ade5 !important; border-radius: 3px; font-size: 14px;}'; -var opener = document.createElement('span'); -opener.innerText = '管理屏蔽列表'; -opener.className = 'fancybutton'; -opener.addEventListener('click', event => { +var opener = btnMaker.make('管理屏蔽列表', event => { if (!show) { banned.forEach(({id, liver}) => makeBanlist(id, liver)); show = true; @@ -38,6 +29,11 @@ opener.addEventListener('click', event => { container.style.display =container.style.display === 'none' ? 'block' : 'none'; }); +var css = document.createElement('style'); +css.innerText = '.fancybox {background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ +.fancymenu {display: none; margin: 10px 10px 0px 10px; grid-template-columns: 49% 49%; grid-gap: 2%}'; +document.head.appendChild(css); + var upload = document.createElement('input'); upload.type = 'file'; upload.accept = '.json'; @@ -125,9 +121,10 @@ function livePlayerInFrame(id) { function applyFilterToArea({menu, room, list}) { setTimeout(() => { - document.querySelector(menu).appendChild(opener); - document.querySelector(menu).after(container); - container.style.top = document.querySelector(menu).offsetTop + 30 + 'px'; + var where = document.querySelector(menu); + where.appendChild(opener); + where.after(container); + container.style.top = where.offsetTop + 30 + 'px'; document.querySelectorAll(room).forEach(addMenuToLiveRoom); list.forEach(item => { new MutationObserver(mutationList => { @@ -145,10 +142,7 @@ function applyFilterToArea({menu, room, list}) { function banInsideLiveRoom(domPlayer, id) { var liver = domPlayer.querySelector('a.room-owner-username').innerText; var area = domPlayer.querySelector('a.area-link').href; - var block = document.createElement('span'); - block.innerText = '屏蔽直播间'; - block.className = 'fancybutton'; - block.addEventListener('click', event => { + var block = btnMaker.make('屏蔽直播间', event => { if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { addBanlist(id, liver); saveBanlist(); @@ -212,21 +206,25 @@ function addMenuToLiveRoom(element) { var preview = element.querySelector('div.Item_2n7ef9LN').style['background-image']; var url = 'https' + preview.slice(preview.indexOf(':'), preview.lastIndexOf('"')); - var menu = document.createElement('div'); - menu.className = 'fancymenu'; - menu.innerHTML = '屏蔽直播间\ -下载封面'; - menu.addEventListener('click', event => { + var block = btnMaker.make('屏蔽直播间', event => { event.preventDefault(); - if (event.target.id === 'bililive_filter_block' && confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { + if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { addBanlist(id, liver); saveBanlist(); } - if (event.target.id === 'bililive_filter_thumb' && confirm('确定要下载直播《' + name + '》的封面吗?')) { + }); + var thumb = btnMaker.make('下载封面', event => { + event.preventDefault(); + if (confirm('确定要下载直播《' + name + '》的封面吗?')) { fetch(url).then(response => response.blob()).then(blob => blobToFile(blob, id + '_' + name)); } }); + + var menu = document.createElement('div'); + menu.className = 'fancymenu'; + menu.append(block, thumb); + element.querySelector('div.Item_2A9JA1Uf').appendChild(menu); - element.addEventListener('mouseover', event => {menu.style.display = 'block';}); + element.addEventListener('mouseover', event => {menu.style.display = 'grid';}); element.addEventListener('mouseout', event => {menu.style.display = 'none';}) } From c2990c27f50da5d4196f9defa712db011f2c196f Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 17:19:38 +0800 Subject: [PATCH 0587/1027] update libs --- RawMangaAssistant.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 2abaebf..d373bb4 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.23 +// @version 6.24 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -15,8 +15,8 @@ // @match *://ney5.xyz/* // @match *://mangahatachi.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= -// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js +// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest From 842c22e63334588f3cc068982be6203de2691c32 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 17:21:33 +0800 Subject: [PATCH 0588/1027] update libs --- NarouSyosetuManager.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index e7f183b..9007ba9 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -6,7 +6,7 @@ // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/metalink4.js#sha256-6oj9bI0kPdhk0XE8OEW9VWwedwSdFxjIirpGaFTAq0A= +// @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue @@ -102,7 +102,7 @@ container.querySelector('#mgr-btn-meta4').addEventListener('click', event => { var json = bookmark.map(book => { book.last = novelist.now; container.querySelector('#' + book.ncode).lastChild.innerHTML = generateTimeFormat(novelist.now); - return {url: ['https://pdfnovels.net/' + book.ncode + '/main.pdf'], name: book.title + '.pdf', locale: 'ja'}; + return {url: [{url: 'https://pdfnovels.net/' + book.ncode + '/main.pdf'}], name: book.title + '.pdf', language: 'ja'}; }); new Metalink4(json).saveAs('小説家になろう書庫'); saveBookmarkButton(); From 41b12e8991ff2faea43e59f83c17601d6663fb6a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 17:26:13 +0800 Subject: [PATCH 0589/1027] update libs --- SpeedRunHelper.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index fae5cba..760ebb4 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -5,7 +5,7 @@ // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* -// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/dragndrop.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= +// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.stripe.com/*", "action": "cancel"} From 5160b870aab7095db07c7cd3f8783c31104fbb9a Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 19:52:24 +0800 Subject: [PATCH 0590/1027] v3.7 better batch block logic --- BilibiliLiveRoomFilter.user.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 943d638..8d61048 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,7 +2,7 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 3.6 +// @version 3.7 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 @@ -19,9 +19,9 @@ var banned = GM_getValue('banned', []); var show = false; var btnMaker = new Button(); -btnMaker.cssText = '.jsui_button {background-color: #23ade5 !important; border-radius: 3px; font-size: 14px;}'; +btnMaker.cssText = '.jsui_button {background-color: #23ade5 !important; border-radius: 3px; font-size: 14px; border: none !important;}'; -var opener = btnMaker.make('管理屏蔽列表', event => { +var opener = btnMaker.make('管理列表', event => { if (!show) { banned.forEach(({id, liver}) => makeBanlist(id, liver)); show = true; @@ -63,13 +63,16 @@ var manager = new Manager([ manager.parentNode = container; function batchBlock(event) { if (confirm('确定要屏蔽列表中的直播间吗?')) { - manager.entry.value.split('\n').forEach(item => { - var rule = item.split(/[\\\/\s,.@#$^&]+/); - if (!isNaN(rule[0])) { - addBanlist(rule[0], rule[1]); - } - }); - saveBanlist(); + var entry = manager.entry.value.match(/[^\n]+/g); + if (entry) { + entry.forEach(item => { + var rule = item.match(/(\d+)[\\\/\|\s\n\(\)\[\]\{\},.:;'"!@#$%^&*]+(.+)/); + if (rule.length === 3) { + addBanlist(rule[1], rule[2]); + } + }); + saveBanlist(); + } manager.entry.value = ''; } } @@ -213,10 +216,10 @@ function addMenuToLiveRoom(element) { saveBanlist(); } }); - var thumb = btnMaker.make('下载封面', event => { + var thumb = btnMaker.make('显示封面', event => { event.preventDefault(); - if (confirm('确定要下载直播《' + name + '》的封面吗?')) { - fetch(url).then(response => response.blob()).then(blob => blobToFile(blob, id + '_' + name)); + if (confirm('确定要打开直播《' + name + '》的封面吗?')) { + open(url, '_blank'); } }); From 39e0395486d2ac963934470695c008e79ccd1767 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 22:43:35 +0800 Subject: [PATCH 0591/1027] v4.0 --- BilibiliLiveRoomFilter.user.js | 104 ++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 8d61048..83029ce 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,13 +2,13 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 3.7 +// @version 4.0 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/button.js -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/manager_0.0.6.js +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js // @grant GM_getValue // @grant GM_setValue // @noframes @@ -18,22 +18,42 @@ var banned = GM_getValue('banned', []); var show = false; -var btnMaker = new Button(); -btnMaker.cssText = '.jsui_button {background-color: #23ade5 !important; border-radius: 3px; font-size: 14px; border: none !important;}'; +var css = document.createElement('style'); +css.type = 'text/css'; +css.innerText = '.jsui_manager {border: 1px solid #000; width: 500px; background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ +.jsui_manager > * {width: 100%; resize: none;}\ +.jsui_button {font-size: 14px; border-width: 0px !important; border-radius: 3px;}\ +.Item_2A9JA1Uf > .jsui_menu {margin: 10px 10px 0px 10px;}'; +document.head.appendChild(css); + +var jsMenu = new JSUI_Menu('#23ade5'); +var menu = jsMenu.menu([ + {label: '批量屏蔽', onclick: batchBlock}, + {label: '导入列表', onclick: importList}, + {label: '导出列表', onclick: exportList}, + {label: '清空列表', onclick: batchUnblock} +]); + +var entry = document.createElement('textarea'); +entry.rows = '6'; + +var jsTable = new JSUI_Table(['直播间ID', '主播昵称']); +jsTable.cssText = '.jsui_table {height: 400px; border: none;}' -var opener = btnMaker.make('管理列表', event => { +var manager = document.createElement('div'); +manager.className = 'jsui_manager'; +manager.style.display = 'none'; +manager.append(menu, entry, jsTable.table); +document.body.appendChild(manager); + +var opener = jsMenu.button('管理列表', event => { if (!show) { banned.forEach(({id, liver}) => makeBanlist(id, liver)); show = true; } - container.style.display =container.style.display === 'none' ? 'block' : 'none'; + manager.style.display = manager.style.display === 'none' ? 'block' : 'none'; }); -var css = document.createElement('style'); -css.innerText = '.fancybox {background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ -.fancymenu {display: none; margin: 10px 10px 0px 10px; grid-template-columns: 49% 49%; grid-gap: 2%}'; -document.head.appendChild(css); - var upload = document.createElement('input'); upload.type = 'file'; upload.accept = '.json'; @@ -50,17 +70,6 @@ upload.addEventListener('change', event => { } }); -var container = document.createElement('div'); -container.className = 'fancybox'; -container.style.display = 'none'; - -var manager = new Manager([ - {label: '批量屏蔽', onclick: batchBlock}, - {label: '导入列表', onclick: importList}, - {label: '导出列表', onclick: exportList}, - {label: '清空列表', onclick: batchUnblock}, -], ['直播间ID', '主播昵称']); -manager.parentNode = container; function batchBlock(event) { if (confirm('确定要屏蔽列表中的直播间吗?')) { var entry = manager.entry.value.match(/[^\n]+/g); @@ -86,7 +95,7 @@ function importList(event) { } function batchUnblock(event) { if (confirm('确定要清空当前屏蔽列表吗?')) { - manager.clear(); + jsTable.clear(); banned = []; saveBanlist(); } @@ -126,8 +135,8 @@ function applyFilterToArea({menu, room, list}) { setTimeout(() => { var where = document.querySelector(menu); where.appendChild(opener); - where.after(container); - container.style.top = where.offsetTop + 30 + 'px'; + where.after(manager); + manager.style.top = where.offsetTop + 30 + 'px'; document.querySelectorAll(room).forEach(addMenuToLiveRoom); list.forEach(item => { new MutationObserver(mutationList => { @@ -145,7 +154,7 @@ function applyFilterToArea({menu, room, list}) { function banInsideLiveRoom(domPlayer, id) { var liver = domPlayer.querySelector('a.room-owner-username').innerText; var area = domPlayer.querySelector('a.area-link').href; - var block = btnMaker.make('屏蔽直播间', event => { + var block = jsMenu.button('屏蔽直播间', event => { if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { addBanlist(id, liver); saveBanlist(); @@ -159,7 +168,7 @@ function banInsideLiveRoom(domPlayer, id) { } function makeBanlist(id, liver) { - manager.add([id, liver], event => { + jsTable.add([id, liver], event => { if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { event.target.parentNode.remove(); var index = banned.findIndex(rule => rule.id === id); @@ -209,25 +218,28 @@ function addMenuToLiveRoom(element) { var preview = element.querySelector('div.Item_2n7ef9LN').style['background-image']; var url = 'https' + preview.slice(preview.indexOf(':'), preview.lastIndexOf('"')); - var block = btnMaker.make('屏蔽直播间', event => { - event.preventDefault(); - if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { - addBanlist(id, liver); - saveBanlist(); - } - }); - var thumb = btnMaker.make('显示封面', event => { - event.preventDefault(); - if (confirm('确定要打开直播《' + name + '》的封面吗?')) { - open(url, '_blank'); - } - }); - - var menu = document.createElement('div'); - menu.className = 'fancymenu'; - menu.append(block, thumb); + var menu = jsMenu.menu([ + {label: '屏蔽直播间', onclick: event => floatBlockLiveRoom(event, id, liver)}, + {label: '打开封面', onclick: event => floatOpenThumbnail(event, url)} + ]); + menu.style.display = 'none'; element.querySelector('div.Item_2A9JA1Uf').appendChild(menu); - element.addEventListener('mouseover', event => {menu.style.display = 'grid';}); + element.addEventListener('mouseover', event => {menu.style.display = 'flex';}); element.addEventListener('mouseout', event => {menu.style.display = 'none';}) } + +function floatBlockLiveRoom(event, id, liver) { + event.preventDefault(); + if (confirm('确定要永久屏蔽【 ' + liver + ' 】的直播间吗?')) { + addBanlist(id, liver); + saveBanlist(); + } +} + +function floatOpenThumbnail(event, url) { + event.preventDefault(); + if (confirm('确定要打开直播《' + name + '》的封面吗?')) { + open(url, '_blank'); + } +} From 355f8f2beb0b4556f72f1fa5c18a4d9f78017de7 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Fri, 16 Sep 2022 23:46:24 +0800 Subject: [PATCH 0592/1027] minor update --- BilibiliLiveRoomFilter.user.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 83029ce..22214de 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,13 +2,13 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.0 +// @version 4.1 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-X+QYZ39cUPJZbzK+YC+/iX625pDAFYdSwRmRZCVNIwI= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-KFMpYP6P28YEilGZsW+VcAWc6d8vKoaTW4SZBuXxAkY= // @grant GM_getValue // @grant GM_setValue // @noframes @@ -22,11 +22,12 @@ var css = document.createElement('style'); css.type = 'text/css'; css.innerText = '.jsui_manager {border: 1px solid #000; width: 500px; background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ .jsui_manager > * {width: 100%; resize: none;}\ -.jsui_button {font-size: 14px; border-width: 0px !important; border-radius: 3px;}\ +.jsui_table {height: 400px; border: none;}\ +.jsui_button {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ .Item_2A9JA1Uf > .jsui_menu {margin: 10px 10px 0px 10px;}'; document.head.appendChild(css); -var jsMenu = new JSUI_Menu('#23ade5'); +var jsMenu = new JSUI_Menu(); var menu = jsMenu.menu([ {label: '批量屏蔽', onclick: batchBlock}, {label: '导入列表', onclick: importList}, @@ -38,7 +39,6 @@ var entry = document.createElement('textarea'); entry.rows = '6'; var jsTable = new JSUI_Table(['直播间ID', '主播昵称']); -jsTable.cssText = '.jsui_table {height: 400px; border: none;}' var manager = document.createElement('div'); manager.className = 'jsui_manager'; From 5b543a899e1abd3d90d45db5908a15a03fffebf6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 11:18:54 +0800 Subject: [PATCH 0593/1027] v4.2 update jsui-menu --- BilibiliLiveRoomFilter.user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 22214de..e0cd8ef 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,12 +2,12 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.1 +// @version 4.2 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-X+QYZ39cUPJZbzK+YC+/iX625pDAFYdSwRmRZCVNIwI= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-JNJVltWNhw5IfbH1dzZG3TuEPUTDGWhmlAjGIWSivyU= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-KFMpYP6P28YEilGZsW+VcAWc6d8vKoaTW4SZBuXxAkY= // @grant GM_getValue // @grant GM_setValue @@ -20,7 +20,7 @@ var show = false; var css = document.createElement('style'); css.type = 'text/css'; -css.innerText = '.jsui_manager {border: 1px solid #000; width: 500px; background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ +css.innerText = '.jsui_manager {border: 2px outset #000; width: 500px; background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ .jsui_manager > * {width: 100%; resize: none;}\ .jsui_table {height: 400px; border: none;}\ .jsui_button {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ @@ -53,6 +53,7 @@ var opener = jsMenu.button('管理列表', event => { } manager.style.display = manager.style.display === 'none' ? 'block' : 'none'; }); +opener.style.width = '120px'; var upload = document.createElement('input'); upload.type = 'file'; From cb8f7ea87503dce45291fa7cd87ebe5874c5f148 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 13:06:01 +0800 Subject: [PATCH 0594/1027] v7.0 use jsui_menu --- RawMangaAssistant.user.js | 160 +++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 90 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index d373bb4..0049f79 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 6.24 +// @version 7.0 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -15,10 +15,11 @@ // @match *://ney5.xyz/* // @match *://mangahatachi.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js -// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js -// @grant GM_getValue +// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-JNJVltWNhw5IfbH1dzZG3TuEPUTDGWhmlAjGIWSivyU= +// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue +// @grant GM_getValue // @grant GM_xmlhttpRequest // @grant GM_webRequest // @webRequest {"selector": "*.googlesyndication.com/*", "action": "cancel"} @@ -66,12 +67,13 @@ var logo = []; var observer; var images; var watching; -var options = GM_getValue('options', {contextmenu: 'on'}); -var {jsonrpc = 'http://localhost:6800/jsonrpc', secret = '', iconTop = 350, iconLeft = 200} = options; +var options = GM_getValue('options', {}) +var {jsonrpc = 'http://localhost:6800/jsonrpc', secret = '', iconTop = 350, iconLeft = 200, ctxMenu = 1} = options; var aria2 = new Aria2(jsonrpc, secret); var folder; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; +var jsMenu = new JSUI_Menu(); // i18n strings and labels var message = { @@ -86,18 +88,16 @@ var message = { done: 'All %n% urls have been copied to clipboard' }, aria2: { - label: 'Send to Aria2 RPC', + label: 'Send to Aria2', done: 'All %n% image urls have been sent to Aria2 RPC', error: 'JSONRPC: Failed to send request' }, gotop: { - label: 'Back to Top', - }, - lazy: { - label: 'Preload All Images' + label: 'Scroll to Top', }, menu: { - label: 'Context Menu Mode' + on: 'Float Button', + off: 'Context Menu' }, extract: { start: 'Extracting manga source', @@ -117,18 +117,18 @@ var message = { done: '%n% 图像链接已复制到剪切板' }, aria2: { - label: '发送至 Aria2 RPC', + label: '发送至 Aria2', done: '全部 %n% 图像链接已发送至Aria2 RPC', error: 'JSONRPC: 请求错误' }, gotop: { label: '回到顶部', }, - lazy: { - label: '预加载所有图像', + float: { + label: '悬浮菜单' }, menu: { - label: '右键菜单模式', + label: '右键菜单', }, extract: { start: '正在解析图像来源', @@ -203,7 +203,6 @@ function extractMangaTitle(title = '') { else { var text = document.querySelector(watching.title.sel).getAttribute(watching.title.attr); var temp = watching.title.reg.exec(text); - console.log(text, temp) title += symbol + temp[watching.title.tl] + symbol + temp[watching.title.ch]; } return title.replace(/[:\?\"\']/g, '_'); @@ -215,47 +214,43 @@ function extractMangaTitle(title = '') { // Create UI var css = document.createElement('style'); -css.innerHTML = '#assistant_button, #assistant_container, #assistant_caution {background-color: #fff; color: #000; position: fixed; z-index: 999999999;}\ -#assistant_button {text-align: center; line-height: 42px; width: 42px !important; height: 42px !important; border: 1px solid darkviolet; top: ' + iconTop + 'px; left: ' + iconLeft + 'px;}\ -#assistant_container {top: ' + iconTop + 'px; left: ' + (iconLeft + 42) + 'px; display: none;}\ -#assistant_container > * {background-color: #fff; width: 220px; border: 1px ridge darkblue; font-size: 14px;}\ -#assistant_container > *:nth-child(-n+2), #assistant_container data {display: none;}\ -#assistant_container.extract > *:nth-child(-n+2), #assistant_container .checked data {display: block;}\ -#assistant_container > * > *, #assistant_caution {line-height: 40px; height: 40px; user-select: none; display: grid; grid-template-columns: 40px auto;}\ -#assistant_container > * > * > *:first-child {text-align: center;}\ -#assistant_caution {font-size: 16px; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center;}\ -#assistant_caution > *:last-child {text-align: left; width: fit-content; padding-right: 10px;}\ -#assistant_button:hover, #assistant_container > * > *:hover {background-color: darkviolet !important; color: white !important;}'; +css.type = 'text/css'; +css.innerText = '.jsui_button {height: 36px; line-height: 26px; background-color: #fff; color: #000 !important;}\ +.jsui_manager {top: ' + (iconTop) + 'px; left: ' + (iconLeft + 38) + 'px; display: none;}\ +.jsui_manager, #assistant_caution {background-color: #fff; z-index: 999999999; position: fixed;}\ +.jsui_dropdown {border: 1px inset darkviolet; width: 120px;}\ +#assistant_caution {font-size: 16px; color: #000 !important; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center; padding: 0px 10px;}\ +#assistant_caution > *:last-child {text-align: left; width: fit-content;}'; -var button = document.createElement('span'); -button.id = 'assistant_button'; -button.innerHTML = '🖱️'; -button.addEventListener('click', event => { +var float = jsMenu.button('🖱️', event => { container.style.display = 'block'; }); +float.style.cssText = 'position: fixed; top: ' + iconTop + 'px; left: ' + iconLeft + 'px; width: 38px; height: 38px; z-index: 999999999; border: 1px inset darkviolet;'; document.addEventListener('click', event => { - container.style.display = button.contains(event.target) ? 'block' : 'none'; + container.style.display = float.contains(event.target) ? 'block' : 'none'; }); var container = document.createElement('div'); -container.id = 'assistant_container'; -container.innerHTML = '
                                      💾' + i18n.save.label + '
                                      \ -
                                      📄' + i18n.copy.label + '
                                      \ -
                                      🖅' + i18n.aria2.label + '
                                      \ -
                                      ⬆️' + i18n.gotop.label + '
                                      '; -document.body.append(button, container, css); +container.className = 'jsui_manager'; +document.body.append(float, container, css); // Draggable button and menu -var dragndrop = new DragNDrop(button); +var dragndrop = new DragNDrop(float); dragndrop.ondragend = event => { container.style.top = dragndrop.offsetTop + 'px'; - container.style.left = dragndrop.offsetLeft + button.offsetWidth + 'px'; - iconTop = dragndrop.offsetTop; - iconLeft = dragndrop.offsetLeft; + container.style.left = dragndrop.offsetLeft + float.offsetWidth + 'px'; + iconTop = iconTop = dragndrop.offsetTop; + iconLeft = iconLeft = dragndrop.offsetLeft; GM_setValue('options', {...options, iconTop, iconLeft}); }; -container.querySelector('#download').addEventListener('click', event => { +var downMenu = jsMenu.menu([ + {label: i18n.save.label, onclick: downloadAllUrls}, + {label: i18n.copy.label, onclick: copyAllUrls}, + {label: i18n.aria2.label, onclick: sendUrlsToAria2} +], true); +downMenu.style.display = 'none'; +function downloadAllUrls() { urls.forEach((url, index) => { GM_xmlhttpRequest({ url, headers, method: 'GET', responseType: 'blob', @@ -271,17 +266,13 @@ container.querySelector('#download').addEventListener('click', event => { } }); }); -}) -container.querySelector('#clipboard').addEventListener('click', event => { +} +function copyAllUrls() { navigator.clipboard.writeText(urls.join('\n')); notification('copy', 'done'); -}); -container.querySelector('#scrolltop').addEventListener('click', event => { - document.documentElement.scrollTop = 0; -}); - +} // Aria2 Menuitems -container.querySelector('#aria2download').addEventListener('click', async event => { +async function sendUrlsToAria2() { folder = folder ?? await aria2.message('aria2.getGlobalOption').then(({dir}) => dir + extractMangaTitle()).catch(error => { alert(i18n.aria2.error); jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; @@ -293,46 +284,32 @@ container.querySelector('#aria2download').addEventListener('click', async event urls.forEach(async(url, index) => aria2.message('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, ...headers}])); notification('aria2', 'done'); } -}); - -// Switchable Menus -var switchMenu = document.createElement('div'); -[ - { - name: 'contextmenu', - on: () => { - button.style.display = 'none'; - document.addEventListener('contextmenu', contextMenuHandler); - }, - off: () => { - document.removeEventListener('contextmenu', contextMenuHandler); - button.style.display = 'block'; - container.style.top = button.offsetTop + 'px'; - container.style.left = button.offsetLeft + button.offsetWidth + 'px'; - } - } -].forEach(({name, on, off}) => { - var menu = document.createElement('div'); - menu.setAttribute('name', name); - menu.innerHTML = '' + i18n.menu.label + '
                                      '; - menu.addEventListener('click', event => { - options[name] = options[name] === 'on' ? 'off' : 'on'; - switchHandler(menu, name, on, off); - GM_setValue('options', options); - }); - switchHandler(menu, name, on, off); - switchMenu.appendChild(menu); -}); -container.appendChild(switchMenu); +} -function switchHandler(menu, name, on, off) { - if (options[name] === 'on') { - on(); - menu.classList.add('checked'); +var modeMenu = jsMenu.menu([ + {label: i18n.gotop.label, onclick: scrollToTop}, + {label: i18n.menu.on, onclick: contextMenuMode} +], true); +function scrollToTop() { + document.documentElement.scrollTop = 0; +} +function contextMenuMode() { + ctxMenu = ctxMenu === 0 ? 1 : 0; + switchMenuMode(); + GM_setValue('options', {...options, ctxMenu}); +} +function switchMenuMode() { + if (ctxMenu === 1) { + float.style.display = 'none'; + modeMenu.childNodes[1].innerText = i18n.menu.on; + document.addEventListener('contextmenu', contextMenuHandler); } else { - off(); - menu.classList.remove('checked'); + float.style.display = 'block'; + modeMenu.childNodes[1].innerText = i18n.menu.off; + document.removeEventListener('contextmenu', contextMenuHandler); + container.style.top = float.offsetTop + 'px'; + container.style.left = float.offsetLeft + float.offsetWidth + 'px'; } } function contextMenuHandler(event) { @@ -344,10 +321,12 @@ function contextMenuHandler(event) { container.style.left = event.clientX + 'px'; container.style.display = 'block'; } +switchMenuMode(); + +container.append(downMenu, modeMenu); // Extract images data if (watching) { - document.body.removeAttribute('id'); if (watching.ads) { removeAdsElement(); } @@ -370,6 +349,7 @@ function removeAdsElement() { function extractImage() { warning = notification('extract', 'start'); + downMenu.style.display = 'block'; observer = setInterval(() => { if (images.length === urls.length + fail.length + logo.length) { warning.remove(); From 53236e4520c4daa840d03375e55390b8110b0eb6 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 13:37:33 +0800 Subject: [PATCH 0595/1027] v4.3: fixed ban inside iframe --- BilibiliLiveRoomFilter.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index e0cd8ef..ec26968 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,7 +2,7 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.2 +// @version 4.3 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 @@ -124,7 +124,7 @@ function livePlayerInFrame(id) { var observer = setInterval(() => { try { var player = document.querySelector('#player-ctnr iframe').contentDocument.querySelector('#head-info-vm > div > div.rows-ctnr'); - player.appendChild(css); + player.append(jsMenu.css, css); banInsideLiveRoom(player, id); clearInterval(observer); } From e837c08d7bc379b0ae0b0bbb45ed2d8493cfe3e4 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 15:33:45 +0800 Subject: [PATCH 0596/1027] update jsui_menu --- RawMangaAssistant.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 0049f79..5379909 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,7 @@ // @match *://mangahatachi.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-JNJVltWNhw5IfbH1dzZG3TuEPUTDGWhmlAjGIWSivyU= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js##sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue // @grant GM_getValue @@ -215,10 +215,10 @@ function extractMangaTitle(title = '') { // Create UI var css = document.createElement('style'); css.type = 'text/css'; -css.innerText = '.jsui_button {height: 36px; line-height: 26px; background-color: #fff; color: #000 !important;}\ +css.innerText = '.jsui_menu_btn {height: 36px; line-height: 26px; background-color: #fff; color: #000 !important;}\ .jsui_manager {top: ' + (iconTop) + 'px; left: ' + (iconLeft + 38) + 'px; display: none;}\ .jsui_manager, #assistant_caution {background-color: #fff; z-index: 999999999; position: fixed;}\ -.jsui_dropdown {border: 1px inset darkviolet; width: 120px;}\ +.jsui_dropdown_menu {border: 1px inset darkviolet; width: 120px;}\ #assistant_caution {font-size: 16px; color: #000 !important; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center; padding: 0px 10px;}\ #assistant_caution > *:last-child {text-align: left; width: fit-content;}'; From fb2dc67e31bbea7d6e97a430db5a5d725de13a5c Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 15:34:14 +0800 Subject: [PATCH 0597/1027] update jsui_menu and jsui_table --- BilibiliLiveRoomFilter.user.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index ec26968..506caf2 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -7,8 +7,8 @@ // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-JNJVltWNhw5IfbH1dzZG3TuEPUTDGWhmlAjGIWSivyU= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-KFMpYP6P28YEilGZsW+VcAWc6d8vKoaTW4SZBuXxAkY= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-IoRecGiToLu0MOgm/MOKaSK4HsW2m8v8f8gj08knlaY= // @grant GM_getValue // @grant GM_setValue // @noframes @@ -23,9 +23,9 @@ css.type = 'text/css'; css.innerText = '.jsui_manager {border: 2px outset #000; width: 500px; background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ .jsui_manager > * {width: 100%; resize: none;}\ .jsui_table {height: 400px; border: none;}\ -.jsui_button {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ +.jsui_menu_btn, .jsui_btn_cell {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ .Item_2A9JA1Uf > .jsui_menu {margin: 10px 10px 0px 10px;}'; -document.head.appendChild(css); +document.body.appendChild(css); var jsMenu = new JSUI_Menu(); var menu = jsMenu.menu([ @@ -169,16 +169,18 @@ function banInsideLiveRoom(domPlayer, id) { } function makeBanlist(id, liver) { - jsTable.add([id, liver], event => { - if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { - event.target.parentNode.remove(); - var index = banned.findIndex(rule => rule.id === id); - if (index !== -1) { - banned.splice(index, 1); - } - saveBanlist(); + jsTable.add([{label: id, onclick: event => removeBanList(event.target.parentNode, id, liver)}, liver]); +} + +function removeBanList(cell, id, liver) { + if (confirm('确定要解除对【 ' + liver + ' 】的屏蔽吗?')) { + cell.remove(); + var index = banned.findIndex(rule => rule.id === id); + if (index !== -1) { + banned.splice(index, 1); } - }); + saveBanlist(); + } } function addBanlist(id, liver) { From 2ae6ea3cf47013622f5b4ba5ab4a4b4dd5b58369 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 17:20:13 +0800 Subject: [PATCH 0598/1027] update jsui_table --- BilibiliLiveRoomFilter.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 506caf2..4b4ec74 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -8,7 +8,7 @@ // @author jc3213 // @match *://live.bilibili.com/* // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-IoRecGiToLu0MOgm/MOKaSK4HsW2m8v8f8gj08knlaY= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-wxnfVu13CEdSl0RlAjyJg44EUyjGLjY8kOJkuET29Ag= // @grant GM_getValue // @grant GM_setValue // @noframes From 238dbfa7789ea322605f40695aa94e33cf3481b5 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 17:46:06 +0800 Subject: [PATCH 0599/1027] v5.0: use jsui_menu and jsui_table --- NarouSyosetuManager.user.js | 222 ++++++++++++++++++++---------------- 1 file changed, 122 insertions(+), 100 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 9007ba9..d83635d 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,12 +1,14 @@ // ==UserScript== // @name 小説家になろう 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 4.9 +// @version 5.0 // @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-wxnfVu13CEdSl0RlAjyJg44EUyjGLjY8kOJkuET29Ag= +// @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js#sha256-rZ1X/YrJghSCBAxFdbk/qBJf85/p6TzWL3FWUeiA7gc= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue @@ -24,62 +26,57 @@ var download = {}; var session = []; var sync = false; var show = false; +var log = false; var bookmark = GM_getValue('bookmark', []); var scheduler = GM_getValue('scheduler', novelist.today); +var jsMenu = new JSUI_Menu(); +var jsTable = new JSUI_Table(['NCODE', '小説タイトル', '更新間隔', 'ダウンロード']); // UI作成関連 var css = document.createElement('style'); -css.innerHTML = '.manager-button {background-color: #fff; text-align: center; padding: 5px; border: 1px outset #000 ; user-select: none ; z-index: 3213; cursor: pointer; font-weight: bold;}\ -.manager-button:hover, .manager-shelf > *:not(:first-child) > *:hover {filter: opacity(75%);}\ -.manager-button:active,.manager-shelf > *:not(:first-child) > *:active {filter: opacity(45%);}\ -.manager-checked {padding: 4px; border: 2px inset #00F;}\ -.manager-container {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ -.manager-menu :not(:first-child) {margin-left: 5px;}\ -.manager-menu input {height: 20px;}\ -.manager-container > div:nth-child(n+2) {margin-top: 5px;}\ -.manager-shelf, .manager-logs {overflow-y: scroll; height: 552px;}\ -.manager-shelf > * {display: grid; grid-template-columns: 100px calc(100% - 306px) 100px 100px; grid-column-gap: 2px; text-align: center;}\ -.manager-shelf > *:first-child > * {background-color: #000; color: #fff;}\ -.manager-shelf > *:nth-child(2n+1):not(:first-child) > * {background-color: #eee;}\ -.manager-shelf > *:not(:first-child) > *:nth-child(2) {text-align: left;}\ -.manager-shelf > *:not(:first-child) > *:nth-child(1) {line-height: 40px;}\ +css.innerHTML = '.jsui_menu_btn {display: block !important; padding: 5px !important;}\ +.jsui_btn_checked {padding: 4px !important; border: 1px inset #00F;}\ +.jsui_table, .jsui_logging {height: 560px; margin-top: 5px; overflow-y: auto;}\ +.jsui_table > * > *:nth-child(2) {flex: 3;}\ +.jsui_manager {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ .notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff;}'; -document.head.appendChild(css); +document.body.appendChild(css); var navi = document.querySelector('#head_nav'); var navi_inner = navi.querySelector('li:last-child'); -var manager = document.createElement('div'); -manager.innerHTML = '書庫管理\ -ダウンロード'; -manager.style.cssText = 'position: absolute; top: 15px; left: ' + (navi_inner.offsetLeft + navi_inner.offsetWidth) + 'px;'; -manager.querySelector('#manager').addEventListener('click', event => { + +var manager = jsMenu.menu([ + {label: '書庫管理', onclick: openBookShelf}, + {label: 'PDF小説', onclick: openPDFNovel} +]); +manager.style.cssText = 'line-height: 40px; font-weight: bold;'; +function openBookShelf() { if (!show) { bookmark.forEach(fancyTableItem); show = true; } - container.style.display = event.target.classList.contains('manager-checked') ? 'none' : 'block'; - event.target.classList.toggle('manager-checked'); -}); -manager.querySelector('#downpdf').addEventListener('click', event => { - event.preventDefault(); - batchDownloadPreHandler(novelist); -}); -(navi ?? document.body).appendChild(manager); + container.style.display = event.target.classList.contains('jsui_btn_checked') ? 'none' : 'block'; + event.target.classList.toggle('jsui_btn_checked'); +} +function openPDFNovel() { + open('https://pdfnovels.net/' + novelist.ncode + '/main.pdf', '_blank'); +} +if (navi) { + navi.appendChild(manager); +} var container = document.createElement('div'); -container.innerHTML = '
                                      NCODE登録\ -\ -NCODE一括更新\ -NCODEをエックスポート\ -\ -
                                      \ -
                                      NCODE小説タイトル更新間隔ダウンロード
                                      \ -'; -container.className = 'manager-container'; +container.className = 'jsui_manager'; container.style.cssText = 'display: none;'; -document.body.appendChild(container); -container.addEventListener('change', event => {novelist.myncode = event.target.value ?? novelist.ncode;}); -container.querySelector('#mgr-btn-subscribe').addEventListener('click', event => { + +var submenu = jsMenu.menu([ + {label: 'NCODE登録', onclick: subscribeCurrentNovel}, + {label: 'NCODE更新', onclick: updateAllNovels}, + {label: 'NCODE保存', onclick: exportAllNovels}, + {label: '書庫更新', onclick: saveAllChanges}, + {label: 'ログ表示', onclick: toggleLogging} +]); +function subscribeCurrentNovel() { var book = bookmark.find(book => book.ncode === novelist.myncode); if (book) { myFancyPopup(book.ncode, book.title, 'は既に書庫に登録しています!'); @@ -91,13 +88,13 @@ container.querySelector('#mgr-btn-subscribe').addEventListener('click', event => else { validateNcode(novelist.myncode); } -}); -container.querySelector('#mgr-btn-update').addEventListener('click', event => { +} +function updateAllNovels() { if (confirm('全ての小説の縦書きPDFをダウンロードしますか?')) { bookmarkSyncPreHandler(() => bookmark.forEach(batchDownloadPreHandler)); } -}); -container.querySelector('#mgr-btn-meta4').addEventListener('click', event => { +} +function exportAllNovels() { if (confirm('全ての小説のダウンロード情報をエックスポートしますか?')) { var json = bookmark.map(book => { book.last = novelist.now; @@ -108,17 +105,84 @@ container.querySelector('#mgr-btn-meta4').addEventListener('click', event => { saveBookmarkButton(); alert('情報のエックスポートは無事に成功しました!'); } -}); -container.querySelector('#mgr-btn-save').addEventListener('click', event => { +} +function saveAllChanges() { GM_setValue('bookmark', bookmark); - container.querySelector('.manager-logs').innerHTML = ''; - container.querySelector('#mgr-btn-save').style.display = container.querySelector('#mgr-btn-log').style.display = 'none'; -}); -container.querySelector('#mgr-btn-log').addEventListener('click', event => { - container.querySelector('.manager-logs').style.display = event.target.classList.contains('manager-checked') ? 'none' : 'block'; - container.querySelector('.manager-shelf').style.display = event.target.classList.contains('manager-checked') ? 'block' : 'none'; - event.target.classList.toggle('manager-checked'); -}); + saveBtn.style.cssText = 'display: none !important'; + logWindow.innerHTML = ''; + jsTable.table.style.display = 'block'; +} +function toggleLogging(event) { + jsTable.table.style.display = event.target.classList.contains('jsui_btn_checked') ? 'block' : 'none'; + event.target.classList.toggle('jsui_btn_checked'); +} + +var saveBtn = submenu.childNodes[3]; +var logBtn = submenu.childNodes[4]; +saveBtn.style.cssText = 'display: none !important'; + +var input = document.createElement('input'); +input.addEventListener('change', event => novelist.myncode = event.target.value ?? novelist.ncode); + +var logWindow = document.createElement('div'); +logWindow.className = 'jsui_logging'; + +submenu.prepend(input); +container.prepend(submenu, jsTable.table, logWindow); +document.body.appendChild(container); + +// ブックマーク表記生成 +function fancyTableItem(book, index) { + var {ncode, title, next, last} = book; + var mybook = jsTable.add([ + {label: ncode, onclick: event => removeNcodeFromShelf(mybook, index, ncode, title)}, + {label: title, onclick: event => openNcodeInNewPage(ncode, title)}, + {label: generateTimeFormat(book.last), onclick: event => downloadCurrentNcode(book, title)} + ]); + + var input = document.createElement('input'); + input.type = 'number'; + input.style.width = '16.666666666666667%'; + input.value = next; + input.title = next === 0 ? 'は更新しないように設定しました!' : 'は ' + next + ' 日間隔で更新するように設定しました!' + input.addEventListener('change', event => changeNcodeUpdatePeriod(book, ncode, title, event.target.value)); + + mybook.lastChild.before(input); + mybook.id = ncode; +} + +function removeNcodeFromShelf(mybook, index, ncode, title) { + if (confirm('【 ' + title + ' 】を書庫から削除しますか?')) { + mybook.remove(); + bookmark.splice(index, 1); + saveBookmarkButton(); + myFancyLog(ncode, title, 'は書庫から削除しました!'); + } +} +function openNcodeInNewPage(ncode, title) { + if (confirm('小説【 ' + title + ' 】を開きますか?')) { + open('https://ncode.syosetu.com/' + ncode + '/', '_blank'); + } +} +function downloadCurrentNcode(book, title) { + if (confirm(title + ' をダウンロードしますか?')) { + updateObserver(1, () => batchDownloadPreHandler(book), saveBookmarkButton); + } +} +function changeNcodeUpdatePeriod(book, ncode, title, value) { + book.next = parseInt(event.target.value); + saveBookmarkButton(); + event.target.title = value === 0 ? '自動更新をしません' : value + '日間隔で更新します'; + myFancyLog(ncode, title, value === 0 ? 'は更新しないように設定しました!' : 'は ' + value + ' 日間隔で更新するように設定しました!'); +} + +function generateTimeFormat(ms) { + var time = new Date(ms); + return time.getFullYear() + '/' + (time.getMonth() + 1) + '/' + time.getDate() + '\n' + time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds(); +} +function saveBookmarkButton() { + saveBtn.style.display = logBtn.style.display = 'block'; +} // NCODE検証&登録 function validateNcode(ncode) { @@ -147,48 +211,6 @@ function subscribeNcode(ncode, title) { myFancyLog(ncode, title, 'は書庫に登録しました!'); } -// ブックマーク表記生成 -function fancyTableItem(book, index) { - var mybook = document.createElement('div'); - mybook.id = book.ncode; - mybook.innerHTML = '' + book.ncode + '\ - ' + book.title + '\ - \ - ' + generateTimeFormat(book.last) + ''; - container.querySelector('.manager-shelf').appendChild(mybook); - mybook.querySelector('#mgr-bk-remove').addEventListener('click', event => { - if (confirm('【 ' + book.title + ' 】を書庫から削除しますか?')) { - mybook.remove(); - bookmark.splice(index, 1); - saveBookmarkButton(); - myFancyLog(book.ncode, book.title, 'は書庫から削除しました!'); - } - }); - mybook.querySelector('#mgr-bk-open').addEventListener('click', event => { - if (confirm('小説【 ' + book.title + ' 】を開きますか?')) { - open('https://ncode.syosetu.com/' + book.ncode + '/', '_blank'); - } - }); - mybook.querySelector('#mgr-bk-update').addEventListener('click', event => { - if (confirm(book.title + ' をダウンロードしますか?')) { - updateObserver(1, () => batchDownloadPreHandler(book), saveBookmarkButton); - } - }); - mybook.addEventListener('change', event => { - book.next = parseInt(event.target.value); - saveBookmarkButton(); - event.target.title = book.next === 0 ? '自動更新をしません' : book.next + '日間隔で更新します'; - myFancyLog(book.ncode, book.title, book.next === 0 ? 'は更新しないように設定しました!' : 'は ' + book.next + ' 日間隔で更新するように設定しました!'); - }); -} -function generateTimeFormat(ms) { - var time = new Date(ms); - return time.getFullYear() + '/' + (time.getMonth() + 1) + '/' + time.getDate() + '\n' + time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds(); -} -function saveBookmarkButton() { - container.querySelector('#mgr-btn-save').style.display = container.querySelector('#mgr-btn-log').style.display = 'inline-block'; -} - // PDF自動更新関連 if (novelist.today !== scheduler) { bookmarkSyncPreHandler(() => bookmark.forEach(updateFancyBookmark)); @@ -203,7 +225,7 @@ function bookmarkSyncPreHandler(start) { }, () => { GM_setValue('bookmark', bookmark); myFancyPopup('', '登録した全てのNコード', 'の更新が完了しました!'); - container.querySelector('.manager-logs').innerHTML = ''; + logWindow.innerHTML = ''; }); } function updateObserver(queue, start, end) { @@ -286,7 +308,7 @@ function myFancyLog(ncode, title, result) { var html = myFancyNcode(ncode, title) + ' ' + result + ''; var log = document.createElement('p'); log.innerHTML = html; - container.querySelector('.manager-logs').prepend(log); + logWindow.prepend(log); myFancyPopup(ncode, title, result); } function myFancyPopup(ncode, title, result) { From 5423d7d14257e5fe42fb61341e0b1ba0b80ff791 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 17:49:57 +0800 Subject: [PATCH 0600/1027] v4.4: update jsui_menu --- BilibiliLiveRoomFilter.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 4b4ec74..795eebc 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,7 +2,7 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.3 +// @version 4.4 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 @@ -24,7 +24,7 @@ css.innerText = '.jsui_manager {border: 2px outset #000; width: 500px; backgroun .jsui_manager > * {width: 100%; resize: none;}\ .jsui_table {height: 400px; border: none;}\ .jsui_menu_btn, .jsui_btn_cell {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ -.Item_2A9JA1Uf > .jsui_menu {margin: 10px 10px 0px 10px;}'; +.Item_2A9JA1Uf > .jsui_basic_menu {margin: 10px 10px 0px 10px;}'; document.body.appendChild(css); var jsMenu = new JSUI_Menu(); From 85f5790e2a204f6fd66e390c6b0597668eeb18d3 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 21:47:14 +0800 Subject: [PATCH 0601/1027] better readability --- BilibiliLiveRoomFilter.user.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 795eebc..4cfb92f 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -169,7 +169,10 @@ function banInsideLiveRoom(domPlayer, id) { } function makeBanlist(id, liver) { - jsTable.add([{label: id, onclick: event => removeBanList(event.target.parentNode, id, liver)}, liver]); + jsTable.add([ + {label: id, onclick: event => removeBanList(event.target.parentNode, id, liver)}, + liver + ]); } function removeBanList(cell, id, liver) { From 3b330575bfe8e17eb598202b6cf7f795c849f007 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sat, 17 Sep 2022 21:48:56 +0800 Subject: [PATCH 0602/1027] v4.5: fixed bug --- BilibiliLiveRoomFilter.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 4cfb92f..25518f2 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,7 +2,7 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.4 +// @version 4.5 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 @@ -215,7 +215,7 @@ function banLiveRoom(element) { } function addMenuToLiveRoom(element) { - if (element.querySelector('div.fancymenu')) { + if (element.querySelector('.jsui_basic_menu')) { return; } var id = banLiveRoom(element); From f5bd1b7498092af456155800e4fa78f1aed6a4c5 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 18 Sep 2022 20:23:15 +0800 Subject: [PATCH 0603/1027] fixed notification and logging --- NarouSyosetuManager.user.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index d83635d..85e7b26 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 小説家になろう 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.0 +// @version 5.1 // @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* @@ -36,10 +36,10 @@ var jsTable = new JSUI_Table(['NCODE', '小説タイトル', '更新間隔', ' var css = document.createElement('style'); css.innerHTML = '.jsui_menu_btn {display: block !important; padding: 5px !important;}\ .jsui_btn_checked {padding: 4px !important; border: 1px inset #00F;}\ -.jsui_table, .jsui_logging {height: 560px; margin-top: 5px; overflow-y: auto;}\ +.jsui_table, .jsui_logging {height: 560px; margin-top: 5px; overflow-y: auto; margin-bottom: 10px;}\ .jsui_table > * > *:nth-child(2) {flex: 3;}\ -.jsui_manager {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px;}\ -.notification {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff;}'; +.jsui_manager {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px; overflow: hidden;}\ +.jsui_notify {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff; z-index: 55555; padding: 10px;}'; document.body.appendChild(css); var navi = document.querySelector('#head_nav'); @@ -143,6 +143,8 @@ function fancyTableItem(book, index) { var input = document.createElement('input'); input.type = 'number'; input.style.width = '16.666666666666667%'; + input.min = '0'; + input.max = '30'; input.value = next; input.title = next === 0 ? 'は更新しないように設定しました!' : 'は ' + next + ' 日間隔で更新するように設定しました!' input.addEventListener('change', event => changeNcodeUpdatePeriod(book, ncode, title, event.target.value)); @@ -314,7 +316,7 @@ function myFancyLog(ncode, title, result) { function myFancyPopup(ncode, title, result) { var popup = document.createElement('div'); popup.innerHTML = myFancyNcode(ncode, title) + ' ' + result + ''; - popup.className = 'notification manager-container'; + popup.className = 'jsui_notify'; popup.style.height = 'fit-content'; popup.addEventListener('click', event => removePopup(popup)); document.body.appendChild(popup); @@ -327,7 +329,7 @@ function myFancyNcode(ncode, title) { ncode && !title ? '' + ncode + '' : ''; } function alignFancyPopup() { - document.querySelectorAll('.notification').forEach((element, index) => { + document.querySelectorAll('.jsui_notify').forEach((element, index) => { element.style.top = (element.offsetHeight + 5) * index + 10 + 'px'; element.style.left = (innerWidth - element.offsetWidth) / 2 + 'px'; }); From 384d13c28b38a5a90c7fad142ce404ec18579797 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Sun, 18 Sep 2022 20:26:04 +0800 Subject: [PATCH 0604/1027] fixed logic --- NarouSyosetuManager.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 85e7b26..82f9d2e 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -147,7 +147,7 @@ function fancyTableItem(book, index) { input.max = '30'; input.value = next; input.title = next === 0 ? 'は更新しないように設定しました!' : 'は ' + next + ' 日間隔で更新するように設定しました!' - input.addEventListener('change', event => changeNcodeUpdatePeriod(book, ncode, title, event.target.value)); + input.addEventListener('change', event => changeNcodeUpdatePeriod(book, ncode, title, event.target.value | 0)); mybook.lastChild.before(input); mybook.id = ncode; @@ -172,7 +172,7 @@ function downloadCurrentNcode(book, title) { } } function changeNcodeUpdatePeriod(book, ncode, title, value) { - book.next = parseInt(event.target.value); + book.next = value; saveBookmarkButton(); event.target.title = value === 0 ? '自動更新をしません' : value + '日間隔で更新します'; myFancyLog(ncode, title, value === 0 ? 'は更新しないように設定しました!' : 'は ' + value + ' 日間隔で更新するように設定しました!'); From 3d410c78e7f307496bab40a06648162000d3bae9 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 10:57:56 +0800 Subject: [PATCH 0605/1027] v5.2: better nitification logic --- NarouSyosetuManager.user.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 82f9d2e..831850d 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 小説家になろう 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.1 +// @version 5.2 // @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* @@ -39,8 +39,12 @@ css.innerHTML = '.jsui_menu_btn {display: block !important; padding: 5px !import .jsui_table, .jsui_logging {height: 560px; margin-top: 5px; overflow-y: auto; margin-bottom: 10px;}\ .jsui_table > * > *:nth-child(2) {flex: 3;}\ .jsui_manager {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px; overflow: hidden;}\ -.jsui_notify {position: fixed; width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff; z-index: 55555; padding: 10px;}'; -document.body.appendChild(css); +.jsui_notify {width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff; z-index: 55555; padding: 10px; margin: 0px auto 5px !important;}'; + +var notify = document.createElement('div'); +notify.style.cssText = 'position: absolute; top: 20px; left: 0px; width: 100%; z-index: 999999;'; + +document.body.append(notify, css); var navi = document.querySelector('#head_nav'); var navi_inner = navi.querySelector('li:last-child'); @@ -317,24 +321,12 @@ function myFancyPopup(ncode, title, result) { var popup = document.createElement('div'); popup.innerHTML = myFancyNcode(ncode, title) + ' ' + result + ''; popup.className = 'jsui_notify'; - popup.style.height = 'fit-content'; - popup.addEventListener('click', event => removePopup(popup)); - document.body.appendChild(popup); - alignFancyPopup(); - setTimeout(() => removePopup(popup), 5000); + popup.addEventListener('click', event => popup.remove()); + notify.appendChild(popup); + setTimeout(() => popup.remove(), 5000); } function myFancyNcode(ncode, title) { return ncode && title ? '「' + title + '」' : !ncode && title ? '' + title + '' : ncode && !title ? '' + ncode + '' : ''; } -function alignFancyPopup() { - document.querySelectorAll('.jsui_notify').forEach((element, index) => { - element.style.top = (element.offsetHeight + 5) * index + 10 + 'px'; - element.style.left = (innerWidth - element.offsetWidth) / 2 + 'px'; - }); -} -function removePopup(popup) { - popup.remove() - alignFancyPopup(); -} From 5c8633251a3eb9993c2f5e47685787c51be6cb06 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 13:49:16 +0800 Subject: [PATCH 0606/1027] v4.6: update jsui --- BilibiliLiveRoomFilter.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 25518f2..2cf501f 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,13 +2,13 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.5 +// @version 4.6 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-wxnfVu13CEdSl0RlAjyJg44EUyjGLjY8kOJkuET29Ag= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-OcdXHP3W0HFg5qNgUiIS7ui35e6dkoNUMCJk2W4HT3Y= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-cqls5oEK/K2Gs8dZbFhByQcBBeUfeaqjwf60dLFyYFo= // @grant GM_getValue // @grant GM_setValue // @noframes From fa30fb6aeeb62557eaf3824f50f90650d25084ce Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 13:50:32 +0800 Subject: [PATCH 0607/1027] Update NarouSyosetuManager.user.js --- NarouSyosetuManager.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 831850d..df07bbe 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,13 +1,13 @@ // ==UserScript== -// @name 小説家になろう 書庫管理 +// @name 「小説家になろう」 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.2 -// @description 小説家になろう の小説情報を管理し、縦書きPDFをダウンロードするツールです +// @version 5.3 +// @description 「小説家になろう」の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-wxnfVu13CEdSl0RlAjyJg44EUyjGLjY8kOJkuET29Ag= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-OcdXHP3W0HFg5qNgUiIS7ui35e6dkoNUMCJk2W4HT3Y= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-cqls5oEK/K2Gs8dZbFhByQcBBeUfeaqjwf60dLFyYFo= // @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js#sha256-rZ1X/YrJghSCBAxFdbk/qBJf85/p6TzWL3FWUeiA7gc= // @connect pdfnovels.net // @grant GM_getValue From 0494674f3ad25f39c69f35810d852f41a5cb37d9 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 14:07:48 +0800 Subject: [PATCH 0608/1027] v7.1: update jsui_menu --- RawMangaAssistant.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 5379909..196ffc4 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 7.0 +// @version 7.1 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -16,7 +16,7 @@ // @match *://mangahatachi.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js##sha256-4uEnJMWpOGBw8mlVCtlVfGWKeofIQaSphaTV6KkP/FI= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-OcdXHP3W0HFg5qNgUiIS7ui35e6dkoNUMCJk2W4HT3Y= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue // @grant GM_getValue From af09e14453e9f6ff7e33303f6c43dd8767ffe0e8 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 16:43:05 +0800 Subject: [PATCH 0609/1027] v4.7: update jsui --- BilibiliLiveRoomFilter.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 2cf501f..024788b 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,13 +2,13 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.6 +// @version 4.7 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-OcdXHP3W0HFg5qNgUiIS7ui35e6dkoNUMCJk2W4HT3Y= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-cqls5oEK/K2Gs8dZbFhByQcBBeUfeaqjwf60dLFyYFo= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= // @grant GM_getValue // @grant GM_setValue // @noframes @@ -23,7 +23,7 @@ css.type = 'text/css'; css.innerText = '.jsui_manager {border: 2px outset #000; width: 500px; background-color: #fff; font-size: 14px; z-index: 999999; position: absolute;}\ .jsui_manager > * {width: 100%; resize: none;}\ .jsui_table {height: 400px; border: none;}\ -.jsui_menu_btn, .jsui_btn_cell {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ +.jsui_menu_btn, .jsui_cell_btn {font-size: 14px; border-width: 0px !important; border-radius: 3px; background-color: #23ade5; color: #fff;}\ .Item_2A9JA1Uf > .jsui_basic_menu {margin: 10px 10px 0px 10px;}'; document.body.appendChild(css); From c01ae0dc98371b78c72173b76a5eb41123a939fe Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 17:28:19 +0800 Subject: [PATCH 0610/1027] v5.4: use jsui_notify --- NarouSyosetuManager.user.js | 45 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index df07bbe..addb9ae 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,13 +1,14 @@ // ==UserScript== // @name 「小説家になろう」 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.3 +// @version 5.4 // @description 「小説家になろう」の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-OcdXHP3W0HFg5qNgUiIS7ui35e6dkoNUMCJk2W4HT3Y= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-cqls5oEK/K2Gs8dZbFhByQcBBeUfeaqjwf60dLFyYFo= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-A45TNLFw+hr8F38gIb9hPRNreQc3r1Yt7y+pkJPWAfc= // @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js#sha256-rZ1X/YrJghSCBAxFdbk/qBJf85/p6TzWL3FWUeiA7gc= // @connect pdfnovels.net // @grant GM_getValue @@ -31,6 +32,7 @@ var bookmark = GM_getValue('bookmark', []); var scheduler = GM_getValue('scheduler', novelist.today); var jsMenu = new JSUI_Menu(); var jsTable = new JSUI_Table(['NCODE', '小説タイトル', '更新間隔', 'ダウンロード']); +var jsNotify = new JSUI_Notify(); // UI作成関連 var css = document.createElement('style'); @@ -38,13 +40,8 @@ css.innerHTML = '.jsui_menu_btn {display: block !important; padding: 5px !import .jsui_btn_checked {padding: 4px !important; border: 1px inset #00F;}\ .jsui_table, .jsui_logging {height: 560px; margin-top: 5px; overflow-y: auto; margin-bottom: 10px;}\ .jsui_table > * > *:nth-child(2) {flex: 3;}\ -.jsui_manager {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px; overflow: hidden;}\ -.jsui_notify {width: fit-content; border-radius: 5px; border: 1px solid #000; background-color: #fff; z-index: 55555; padding: 10px; margin: 0px auto 5px !important;}'; - -var notify = document.createElement('div'); -notify.style.cssText = 'position: absolute; top: 20px; left: 0px; width: 100%; z-index: 999999;'; - -document.body.append(notify, css); +.jsui_manager {position: fixed; top: 47px; left: calc(50% - 440px); background-color: #fff; padding: 10px; z-index: 3213; border: 1px solid #CCC; width: 880px; height: 600px; overflow: hidden;}'; +document.body.appendChild(css); var navi = document.querySelector('#head_nav'); var navi_inner = navi.querySelector('li:last-child'); @@ -311,22 +308,20 @@ function downloadPDFHandler(book) { // ログ関連 function myFancyLog(ncode, title, result) { - var html = myFancyNcode(ncode, title) + ' ' + result + ''; + if (ncode && title) { + var html = '「' + title + '' + result + ''; + var message = 'Nコード【' + ncode + '】、「' + title + '」' + result; + } + else if (ncode === undefined && title) { + html = '' + title + ' ' + result + ''; + message = '「' + title + '」' + result; + } + else if (ncode && title === undefined) { + html = '' + ncode + ' ' + result + ''; + message = 'Nコード【' + ncode + '】' + result; + } var log = document.createElement('p'); log.innerHTML = html; logWindow.prepend(log); - myFancyPopup(ncode, title, result); -} -function myFancyPopup(ncode, title, result) { - var popup = document.createElement('div'); - popup.innerHTML = myFancyNcode(ncode, title) + ' ' + result + ''; - popup.className = 'jsui_notify'; - popup.addEventListener('click', event => popup.remove()); - notify.appendChild(popup); - setTimeout(() => popup.remove(), 5000); -} -function myFancyNcode(ncode, title) { - return ncode && title ? '「' + title + '」' : - !ncode && title ? '' + title + '' : - ncode && !title ? '' + ncode + '' : ''; + jsNotify.popup({message}); } From 63a8da79d6e89de07447a0cafa33567b5a43f1b5 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 17:42:35 +0800 Subject: [PATCH 0611/1027] v7.2: use jsui_notify --- RawMangaAssistant.user.js | 64 +++++++++++++++------------------------ 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 196ffc4..d0dc2ae 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 7.1 +// @version 7.2 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -15,8 +15,9 @@ // @match *://ney5.xyz/* // @match *://mangahatachi.com/* // @connect * +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-A45TNLFw+hr8F38gIb9hPRNreQc3r1Yt7y+pkJPWAfc= // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-OcdXHP3W0HFg5qNgUiIS7ui35e6dkoNUMCJk2W4HT3Y= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue // @grant GM_getValue @@ -74,22 +75,23 @@ var folder; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; var jsMenu = new JSUI_Menu(); +var jsNotify = new JSUI_Notify(); // i18n strings and labels var message = { 'en-US': { save: { label: 'Download', - done: 'All %n% images have been successfully downloaded', - error: 'Some image can\'t be downloaded' + done: 'All %n% images have been successfully downloaded', + error: 'Some image can\'t be downloaded' }, copy: { label: 'Copy Urls', - done: 'All %n% urls have been copied to clipboard' + done: 'All %n% urls have been copied to clipboard' }, aria2: { label: 'Send to Aria2', - done: 'All %n% image urls have been sent to Aria2 RPC', + done: 'All %n% image urls have been sent to Aria2 JSON-RPC', error: 'JSONRPC: Failed to send request' }, gotop: { @@ -100,25 +102,25 @@ var message = { off: 'Context Menu' }, extract: { - start: 'Extracting manga source', - done: 'A total of %n% image urls have been extracted', - fail: 'Download function not available due to extraction failure', - error: 'Can\'t be extracted image extension' + start: 'Extracting manga source', + done: 'A total of %n% image urls have been extracted', + fail: 'Download function not available due to extraction failure', + error: 'Can\'t be extracted image extension' } }, 'zh-CN': { save: { label: '下载图像', - done: '已成功下载全部 %n% 图像', - error: '无法下载>%部分图像', + done: '已成功下载全部 %n% 图像', + error: '无法下载部分图像', }, copy: { label: '复制链接', - done: '%n% 图像链接已复制到剪切板' + done: '%n% 图像链接已复制到剪切板' }, aria2: { label: '发送至 Aria2', - done: '全部 %n% 图像链接已发送至Aria2 RPC', + done: '全部 %n% 图像链接已发送至Aria2 JSON-RPC', error: 'JSONRPC: 请求错误' }, gotop: { @@ -131,10 +133,10 @@ var message = { label: '右键菜单', }, extract: { - start: '正在解析图像来源', - done: '已成功解析全部 %n% 图像来源', - fail: '无法解析图像来源,下载功能无法使用', - error: '无法解析图像后缀' + start: '正在解析图像来源', + done: '已成功解析全部 %n% 图像来源', + fail: '无法解析图像来源,下载功能无法使用', + error: '无法解析图像后缀' } } }; @@ -217,10 +219,9 @@ var css = document.createElement('style'); css.type = 'text/css'; css.innerText = '.jsui_menu_btn {height: 36px; line-height: 26px; background-color: #fff; color: #000 !important;}\ .jsui_manager {top: ' + (iconTop) + 'px; left: ' + (iconLeft + 38) + 'px; display: none;}\ -.jsui_manager, #assistant_caution {background-color: #fff; z-index: 999999999; position: fixed;}\ +.jsui_manager {background-color: #fff; z-index: 999999999; position: fixed;}\ .jsui_dropdown_menu {border: 1px inset darkviolet; width: 120px;}\ -#assistant_caution {font-size: 16px; color: #000 !important; border: 1px ridge darkviolet; border-radius: 5px; height: 60px; line-height: 60px; text-align: center; padding: 0px 10px;}\ -#assistant_caution > *:last-child {text-align: left; width: fit-content;}'; +.jsui_notify_popup {color: #000;}'; var float = jsMenu.button('🖱️', event => { container.style.display = 'block'; @@ -355,7 +356,6 @@ function extractImage() { warning.remove(); clearInterval(observer); if (fail.length === 0) { - container.classList.add('extract'); notification('extract', 'done'); } else { @@ -404,23 +404,7 @@ function appendShortcuts() { // Notifications function notification(action, status, url) { var warn = i18n[action][status] ?? i18n[action]; - var html = '⚠️' + warn.replace('%n%', '' + images.length + (url ? '

                                      ' + url + '

                                      ' : '') + '
                                      ') + '
                                      '; + var message = '⚠️ ' + warn.replace('%n%', images.length); var caution = document.createElement('div'); - caution.id = 'assistant_caution'; - caution.innerHTML = html; - document.body.appendChild(caution); - align_notification(); - if (action === 'extract' && ['start', 'fail'].includes(status)) { - return caution; - } - setTimeout(() => { - caution.remove(); - align_notification(); - }, 3000); -} -function align_notification() { - document.querySelectorAll('#assistant_caution').forEach((element, index) => { - element.style.top = index * (element.offsetHeight + 5) + 10 + 'px'; - element.style.left = (document.documentElement.clientWidth - element.offsetWidth) / 2 + 'px'; - }); + return jsNotify.popup({message}); } From 582cecb5afe780ab76313aeeddf78a14f41709ad Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 17:47:53 +0800 Subject: [PATCH 0612/1027] v5.4: use jsui_notify --- NarouSyosetuManager.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index addb9ae..7d73360 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -8,7 +8,7 @@ // @match *://novel18.syosetu.com/n* // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-A45TNLFw+hr8F38gIb9hPRNreQc3r1Yt7y+pkJPWAfc= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-l+O3NmbpqsqPQjnVzGw+x2Bea9bH07i0ZkMZv9EbsOo= // @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js#sha256-rZ1X/YrJghSCBAxFdbk/qBJf85/p6TzWL3FWUeiA7gc= // @connect pdfnovels.net // @grant GM_getValue From 4577eb48ff57c492b77e7844767fb88ac155d22b Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 17:49:28 +0800 Subject: [PATCH 0613/1027] v7.2: use jsui_notify --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index d0dc2ae..61da8ec 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,7 @@ // @match *://mangahatachi.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-A45TNLFw+hr8F38gIb9hPRNreQc3r1Yt7y+pkJPWAfc= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-l+O3NmbpqsqPQjnVzGw+x2Bea9bH07i0ZkMZv9EbsOo= // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue From 3ed17dd9075987ee172136b52f57162aac0fe4f7 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 19:27:40 +0800 Subject: [PATCH 0614/1027] update jsui_notify --- RawMangaAssistant.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 61da8ec..62e7af0 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -16,7 +16,7 @@ // @match *://mangahatachi.com/* // @connect * // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-l+O3NmbpqsqPQjnVzGw+x2Bea9bH07i0ZkMZv9EbsOo= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= // @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue From 966aa91571c82c708baa756d81fb79bf8a3139df Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 19:28:01 +0800 Subject: [PATCH 0615/1027] update jsui_notify --- NarouSyosetuManager.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 7d73360..a952551 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -8,7 +8,7 @@ // @match *://novel18.syosetu.com/n* // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-l+O3NmbpqsqPQjnVzGw+x2Bea9bH07i0ZkMZv9EbsOo= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= // @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js#sha256-rZ1X/YrJghSCBAxFdbk/qBJf85/p6TzWL3FWUeiA7gc= // @connect pdfnovels.net // @grant GM_getValue From bee96a07084831414cf179e48313bf57d4fedf38 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 20:50:20 +0800 Subject: [PATCH 0616/1027] v7.3: use jslib_aria2 --- RawMangaAssistant.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 62e7af0..52fd4c0 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 7.2 +// @version 7.3 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -17,7 +17,7 @@ // @connect * // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= -// @require https://raw.githubusercontent.com/jc3213/aria2.js/main/src/aria2_0.3.13.js#sha256-r3LIgBfC9ZzXT6/iO7seAHC3hpRmTHuy1tXsHTV5UPY= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/aria2.js#sha256-LGfZDbCTb8Mer2mpV76Q3P1oZp1Kq/h0wTkXTDGbBFQ= // @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= // @grant GM_setValue // @grant GM_getValue From 3f6108f11eb5dae9e59e310961bc5ff56b890af3 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 20:59:58 +0800 Subject: [PATCH 0617/1027] v5.5: use jslib_meta4 --- NarouSyosetuManager.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index a952551..a25dc31 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 「小説家になろう」 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.4 +// @version 5.5 // @description 「小説家になろう」の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* @@ -9,7 +9,7 @@ // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= -// @require https://raw.githubusercontent.com/jc3213/metalink4.js/main/src/metalink4_0.2.0.js#sha256-rZ1X/YrJghSCBAxFdbk/qBJf85/p6TzWL3FWUeiA7gc= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/meta4.js#sha256-uH26nJrjXzN4AOPJq+8JtaC71S8Y6mw+/ZcoMCLy4Uk= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue From 54d166f2c271715acb0bfcc5a5655943e96b6546 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 21:47:20 +0800 Subject: [PATCH 0618/1027] v5.6: update jslib_meta4 --- NarouSyosetuManager.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index a25dc31..b1387bd 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 「小説家になろう」 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.5 +// @version 5.6 // @description 「小説家になろう」の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* @@ -9,7 +9,7 @@ // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/meta4.js#sha256-uH26nJrjXzN4AOPJq+8JtaC71S8Y6mw+/ZcoMCLy4Uk= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/meta4.js#sha256-8oJGm7Zsi8y7Xp9xS8YBgJ7J93K7Jo6a8dOWB/j7O2M= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue @@ -102,7 +102,7 @@ function exportAllNovels() { container.querySelector('#' + book.ncode).lastChild.innerHTML = generateTimeFormat(novelist.now); return {url: [{url: 'https://pdfnovels.net/' + book.ncode + '/main.pdf'}], name: book.title + '.pdf', language: 'ja'}; }); - new Metalink4(json).saveAs('小説家になろう書庫'); + new JSLib_Meta4(json).saveAs('小説家になろう書庫'); saveBookmarkButton(); alert('情報のエックスポートは無事に成功しました!'); } From 5b4461e36650572982703e7ad5e37098b8699e83 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Mon, 19 Sep 2022 23:59:05 +0800 Subject: [PATCH 0619/1027] v7.4: update drag'n'drop, fixed storage --- RawMangaAssistant.user.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index 52fd4c0..ae77f68 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 7.3 +// @version 7.4 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -18,7 +18,7 @@ // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= // @require https://raw.githubusercontent.com/jc3213/jslib/main/src/aria2.js#sha256-LGfZDbCTb8Mer2mpV76Q3P1oZp1Kq/h0wTkXTDGbBFQ= -// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js#sha256-CH+YUPZysVw/cMUTlFCECh491u7VvspceftzLGzhY3g= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest @@ -68,9 +68,10 @@ var logo = []; var observer; var images; var watching; -var options = GM_getValue('options', {}) +var options = GM_getValue('options', {}); +console.log(options); var {jsonrpc = 'http://localhost:6800/jsonrpc', secret = '', iconTop = 350, iconLeft = 200, ctxMenu = 1} = options; -var aria2 = new Aria2(jsonrpc, secret); +var aria2 = new JSLib_Aria2(jsonrpc, secret); var folder; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; @@ -236,14 +237,14 @@ container.className = 'jsui_manager'; document.body.append(float, container, css); // Draggable button and menu -var dragndrop = new DragNDrop(float); -dragndrop.ondragend = event => { - container.style.top = dragndrop.offsetTop + 'px'; - container.style.left = dragndrop.offsetLeft + float.offsetWidth + 'px'; - iconTop = iconTop = dragndrop.offsetTop; - iconLeft = iconLeft = dragndrop.offsetLeft; - GM_setValue('options', {...options, iconTop, iconLeft}); -}; +draggableElement(float, ({offsetTop, offsetLeft}) => { + container.style.top = offsetTop + 1 + 'px'; + container.style.left = offsetLeft + 39 + 'px'; + iconTop = offsetTop; + iconLeft = offsetLeft; + options = {...options, iconTop, iconLeft} + GM_setValue('options', options); +}); var downMenu = jsMenu.menu([ {label: i18n.save.label, onclick: downloadAllUrls}, @@ -278,8 +279,9 @@ async function sendUrlsToAria2() { alert(i18n.aria2.error); jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; secret = prompt('Aria2 Secret Token', secret ) ?? secret; - aria2 = new Aria2(jsonrpc, secret); - GM_setValue('options', {...options, jsonrpc, secret}); + aria2 = new JSLib_Aria2(jsonrpc, secret); + options = {...options, jsonrpc, secret}; + GM_setValue('options', options); }); if (folder) { urls.forEach(async(url, index) => aria2.message('aria2.addUri', [[url], {out: longDecimalNumber(index) + '.' + url.match(/(png|jpg|jpeg|webp)/)[0], dir: folder, ...headers}])); @@ -297,7 +299,8 @@ function scrollToTop() { function contextMenuMode() { ctxMenu = ctxMenu === 0 ? 1 : 0; switchMenuMode(); - GM_setValue('options', {...options, ctxMenu}); + options = {...options, ctxMenu}; + GM_setValue('options', options); } function switchMenuMode() { if (ctxMenu === 1) { From 9a00857b92db05e5193dfc5a063a7c75b3394813 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 20 Sep 2022 00:01:58 +0800 Subject: [PATCH 0620/1027] v3.6: update draggable.js --- SpeedRunHelper.user.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 760ebb4..0212b8b 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.5 +// @version 3.6 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* -// @require https://raw.githubusercontent.com/jc3213/dragndrop.js/main/src/dragndrop_0.1.0.js +// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.stripe.com/*", "action": "cancel"} @@ -95,7 +95,6 @@ function createRecordWindow(id, title, content) { var container = document.createElement('div'); container.id = 'speedrun-' + id; container.idx = document.querySelectorAll('.speedrun-window').length; - container.draggable = 'true'; container.className = 'speedrun-window'; container.innerHTML = '
                                      ' + title + '
                                      \
                                      \ @@ -123,13 +122,12 @@ function createRecordWindow(id, title, content) { container.querySelector('#speedrun-close').addEventListener('click', event => { container.remove(); }); - var dragndrop = new DragNDrop(container, document.querySelector('nav').parentNode.offsetHeight); - dragndrop.ondragend = event => { + draggableElement(container, position => { if (container.className === 'speedrun-window') { style[id] = container.style.cssText; } else { container.style.cssText = ''; } - }; + }); } From 427f8de49dd55da2adbfc486fe3a0179680fb1d7 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 20 Sep 2022 09:35:22 +0800 Subject: [PATCH 0621/1027] v5.7: update libs --- NarouSyosetuManager.user.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index b1387bd..ab20829 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,15 +1,15 @@ // ==UserScript== // @name 「小説家になろう」 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.6 +// @version 5.7 // @description 「小説家になろう」の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/meta4.js#sha256-8oJGm7Zsi8y7Xp9xS8YBgJ7J93K7Jo6a8dOWB/j7O2M= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-Cras2dh1/vJid5qUF5zZmNlt7hXmYpC9kQEZ+5yY5cM= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/metalink4.js#sha256-KrcYnyS4fuAruLmyc1zQab2cd+YRfF98S4BupoTVz+A= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue @@ -102,7 +102,13 @@ function exportAllNovels() { container.querySelector('#' + book.ncode).lastChild.innerHTML = generateTimeFormat(novelist.now); return {url: [{url: 'https://pdfnovels.net/' + book.ncode + '/main.pdf'}], name: book.title + '.pdf', language: 'ja'}; }); - new JSLib_Meta4(json).saveAs('小説家になろう書庫'); + var metalink = metalink4(json); + var blob = new Blob([metalink], {type: 'application/metalink+xml; charset=utf-8'}) + var a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = '小説家になろう書庫-' + new Date().toJSON().slice(0, -2).replace(/[T:\.\-]/g, '_') + '.meta4'; + a.click(); + a.remove(); saveBookmarkButton(); alert('情報のエックスポートは無事に成功しました!'); } From 08321c6673fc6562b81da5245a9db7fdc3af1354 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Tue, 20 Sep 2022 21:37:20 +0800 Subject: [PATCH 0622/1027] v3.16: use jsui_button --- BilibiliVideoDownloader.user.js | 96 ++++++++++++++++----------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 58bc3b1..35e582a 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -7,14 +7,16 @@ // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 // @match *://www.bilibili.com/video/* +// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @run-at document-end // ==/UserScript== var {autowide = '0', videocodec = '0'} = localStorage; var [toolbar, widescreen, widestate, next, prev] = location.pathname.startsWith('/video/') ? ['#arc_toolbar_report', 'div.bpx-player-ctrl-wide', 'bpx-state-entered', 'div.bpx-player-ctrl-next', 'div.bpx-player-ctrl-prev'] : ['#toolbar_module', 'div.squirtle-video-widescreen', 'active', 'div.squirtle-video-next']; +var watching; var title; -var video; var worker; +var jsMenu = new JSUI_Menu(); var format = { '30280': {label: '音频 高码率', ext: '.192k.aac'}, '30232': {label: '音频 中码率', ext: '.128k.aac'}, @@ -36,27 +38,24 @@ var format = { }; var css = document.createElement('style'); -css.innerHTML = '#helper-main {position: relative; z-index: 9999; display: inline-block; user-select: none;}\ -#helper-options, #helper-analyse {position: absolute; border: 1px solid #000; padding: 5px; top: 40px; left: 0px; background-color: #fff;}\ -#helper-options {width: 115px;}\ -#helper-options p, #helper-options select, .helper-button {font-size: 16px; text-align: center; padding: 5px;}\ -#helper-options p, #helper-options option:checked {color: #c26; font-weight: bold;}\ -#helper-options select {width: 100%;}\ -#helper-analyse {width: 400px;}\ -#helper-analyse ul {display: inline-block; margin-righ: 3px; vertical-align: top;}\ -#helper-analyse a {display: inline-block; width: 100px;}\ -.helper-button {background-color: #c26; color: #fff; height: 16px; line-height: 16px; padding: 10px 15px; display: inline-block; margin: 0px 3px 3px 0px; cursor: pointer;}\ -.helper-button:hover {background-color: #26c;}'; +css.innerHTML = '.jsui_menu_btn {background-color: #c26; color: #fff; font-size: 16px;}\ +.jsui_dropdown_menu {flex: 1;}\ +.jsui_analyse {display: flex; width: 400px;}\ +.jsui_options {width: 150px;}\ +.jsui_options, .jsui_analyse {position: absolute; border: 1px solid #000; padding: 5px; top: 48px; left: 0px; background-color: #fff;}\ +.jsui_options * {font-size: 16px; text-align: center; padding: 5px; width: 100%;}\ +.jsui_options p, .jsui_options option:checked {color: #c26; font-weight: bold;}'; -var menu = document.createElement('div'); -menu.id = 'helper-main'; -menu.innerHTML = '设置解析'; -menu.querySelector('#options').addEventListener('click', event => { +var menu = jsMenu.menu([ + {label: '设置', onclick: openOptions}, + {label: '解析', onclick: analyseVideo} +]); +menu.style.cssText = 'position: relative; z-index: 9999; top: -6px; left: -60px; width: 160px;'; +function openOptions() { analyse.style.display = 'none'; options.style.display = options.style.display === 'none' ? 'block' : 'none'; -}); -menu.querySelector('#analyse').addEventListener('click', async event => { - options.style.display = 'none'; +} +async function analyseVideo() { if (worker || videocodec !== localStorage.videocodec) { worker = false; videocodec = localStorage.videocodec; @@ -67,8 +66,9 @@ menu.querySelector('#analyse').addEventListener('click', async event => { biliVideoThumbnail(thumb); await biliVideoExtractor(playurl, key); } - analyse.style.display = analyse.style.display === 'none' ? 'block' : 'none'; -}); + options.style.display = 'none'; + analyse.style.display = analyse.style.display === 'none' ? 'flex' : 'none'; +} document.addEventListener('keydown', event => { if (event.ctrlKey) { @@ -82,17 +82,18 @@ document.addEventListener('keydown', event => { }); var options = document.createElement('div'); -options.id = 'helper-options'; +options.className = 'jsui_options'; options.innerHTML = '

                                      自动宽屏

                                      \

                                      优先编码

                                      '; options.querySelector('#autowide').value = autowide; options.querySelector('#videocodec').value = videocodec; options.addEventListener('change', event => { - localStorage[event.target.id] = event.target.value; + var {id, value} = event.target; + localStorage[id] = value; }); var analyse = document.createElement('div'); -analyse.id = 'helper-analyse'; +analyse.className = 'jsui_analyse'; menu.append(options, analyse, css); options.style.display = analyse.style.display = 'none'; @@ -101,15 +102,15 @@ var observer = setInterval(() => { var widebtn = document.querySelector(widescreen); if (widebtn) { clearInterval(observer); - document.querySelector(toolbar).append(menu, css); + document.querySelector(toolbar).append(menu); if (!widebtn.classList.contains(widestate) && autowide === '1' ) { widebtn.click(); } } }, 200); new MutationObserver(mutations => { - if (video !== location.pathname) { - video = location.pathname; + if (watching !== location.pathname) { + watching = location.pathname; worker = true; options.style.display = analyse.style.display = 'none'; } @@ -122,39 +123,34 @@ function biliVideoTitle(name) { } function biliVideoThumbnail(url) { - var top = document.createElement('ul'); var fixed = url.replace(/^(https?:)?\/\//, 'https://') - var sub = createMenuitem('视频封面', fixed, url.slice(url.lastIndexOf('.'))); - top.append(sub); - analyse.append(top); + var menu = jsMenu.menu([ + {label: '视频封面', onclick: event => downloadBiliVideo(event, fixed, title + url.slice(url.lastIndexOf('.')))} + ], true); + analyse.appendChild(menu); } async function biliVideoExtractor(playurl, key) { - var menu = {av1: document.createElement('ul'), hevc: document.createElement('ul'), avc: document.createElement('ul'), aac: document.createElement('ul')}; var response = await fetch('https://api.bilibili.com/' + playurl + '&fnval=4050', {credentials: 'include'}); var json = await response.json(); + menu = {avc1: [], hev1: [], av01: [], mp4a: []}; var {video, audio} = json[key].dash; - [...video, ...audio].forEach(({id, mimeType, codecs, baseUrl}) => { + [...video, ...audio].forEach(({id, codecs, baseUrl}) => { var codec = codecs.slice(0, codecs.indexOf('.')); - var top = codec === 'avc1' ? menu.avc : codec === 'hev1' ? menu.hevc : codec === 'av01' ? menu.av1 : menu.aac; var {label, ext} = format[id]; - var sub = createMenuitem(label, baseUrl, '.' + codec + ext, codec); - top.appendChild(sub); + menu[codec].push({label, onclick: event => downloadBiliVideo(event, baseUrl, title + ext)}); }); - var codec = videocodec === '2' ? menu.av1.childNodes.length !== 0 ? menu.av1 : menu.hevc.childNodes.length !== 0 ? menu.hevc : menu.avc : videocodec === '1' && menu.hevc.childNodes.length !== 0 ? menu.hevc : menu.avc; - analyse.append(codec, menu.aac) + video = jsMenu.menu(videocodec === '2' ? menu.av01.length !== 0 ? menu.av01 : menu.hev1.length !== 0 ? menu.hev1 : menu.avc1 : videocodec === '1' && menu.hev1.length !== 0 ? menu.hev1 : menu.avc1, true); + audio = jsMenu.menu(menu.mp4a, true); + analyse.append(video, audio); } -function createMenuitem(label, url, ext, codec) { - var li = document.createElement('li'); - var tip = codec === undefined ? '' : format[codec] ? format[codec] : '未知编码: ' + codec; - li.innerHTML = '' + label + ''; - li.addEventListener('click', event => { - if (event.ctrlKey) { - event.preventDefault(); - var aria2 = JSON.stringify({url, options: {out: title + ext, referer: location.href}}); - navigator.clipboard.writeText(aria2); - } - }); - return li; +function downloadBiliVideo(event, url, name) { + if (event.ctrlKey) { + var aria2 = JSON.stringify({url, options: {out: name, referer: location.href}}); + navigator.clipboard.writeText(aria2); + } + else { + open(url, '_blank'); + } } From 0a9f73f7ec1acaca41b2280adebad4a9e31fcc17 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:32:21 +0800 Subject: [PATCH 0623/1027] v7.6: update libs --- RawMangaAssistant.user.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index ae77f68..e5c8e72 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -2,7 +2,7 @@ // @name Raw Manga Assistant // @name:zh 漫画生肉网站助手 // @namespace https://github.com/jc3213/userscript -// @version 7.4 +// @version 7.6 // @description Assistant for raw manga online website // @description:zh 漫画生肉网站助手脚本 // @author jc3213 @@ -15,10 +15,10 @@ // @match *://ney5.xyz/* // @match *://mangahatachi.com/* // @connect * -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-ipix2NKY580tY2Zpnf93Z0C8BC7UVR4wQM1kEhbmOA0= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/aria2.js#sha256-LGfZDbCTb8Mer2mpV76Q3P1oZp1Kq/h0wTkXTDGbBFQ= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/notify.js#sha256-Cras2dh1/vJid5qUF5zZmNlt7hXmYpC9kQEZ+5yY5cM= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/lib/aria2.js#sha256-3mm3pLgUtNGzHaFHvoclOtHCz+K6juHsJfNAIor+6n8= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/lib/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest @@ -69,9 +69,8 @@ var observer; var images; var watching; var options = GM_getValue('options', {}); -console.log(options); var {jsonrpc = 'http://localhost:6800/jsonrpc', secret = '', iconTop = 350, iconLeft = 200, ctxMenu = 1} = options; -var aria2 = new JSLib_Aria2(jsonrpc, secret); +var aria2 = new Aria2(jsonrpc, secret); var folder; var warning; var headers = {'cookie': document.cookie, 'referer': location.href, 'user-agent': navigator.userAgent}; @@ -279,7 +278,7 @@ async function sendUrlsToAria2() { alert(i18n.aria2.error); jsonrpc = prompt('Aria2 JSONRPC URI', jsonrpc) ?? jsonrpc; secret = prompt('Aria2 Secret Token', secret ) ?? secret; - aria2 = new JSLib_Aria2(jsonrpc, secret); + aria2 = new Aria2(jsonrpc, secret); options = {...options, jsonrpc, secret}; GM_setValue('options', options); }); From 68f2baf7d11120a856e212c7f405b68c344901cd Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:33:49 +0800 Subject: [PATCH 0624/1027] update libs --- NarouSyosetuManager.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index ab20829..761a6d8 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -1,15 +1,15 @@ // ==UserScript== // @name 「小説家になろう」 書庫管理 // @namespace https://github.com/jc3213/userscript -// @version 5.7 +// @version 5.8 // @description 「小説家になろう」の小説情報を管理し、縦書きPDFをダウンロードするツールです // @author jc3213 // @match *://ncode.syosetu.com/n* // @match *://novel18.syosetu.com/n* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/notify.js#sha256-Cras2dh1/vJid5qUF5zZmNlt7hXmYpC9kQEZ+5yY5cM= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/metalink4.js#sha256-KrcYnyS4fuAruLmyc1zQab2cd+YRfF98S4BupoTVz+A= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/notify.js#sha256-Cras2dh1/vJid5qUF5zZmNlt7hXmYpC9kQEZ+5yY5cM= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/lib/metalink4.js#sha256-KrcYnyS4fuAruLmyc1zQab2cd+YRfF98S4BupoTVz+A= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue From cd168738d2f786dff5f1a90c049b238f803ccc6f Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:35:41 +0800 Subject: [PATCH 0625/1027] v7.6 --- NarouSyosetuManager.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NarouSyosetuManager.user.js b/NarouSyosetuManager.user.js index 761a6d8..b54fd2e 100644 --- a/NarouSyosetuManager.user.js +++ b/NarouSyosetuManager.user.js @@ -9,7 +9,7 @@ // @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= // @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/notify.js#sha256-Cras2dh1/vJid5qUF5zZmNlt7hXmYpC9kQEZ+5yY5cM= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/lib/metalink4.js#sha256-KrcYnyS4fuAruLmyc1zQab2cd+YRfF98S4BupoTVz+A= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/js/metalink4.js#sha256-KrcYnyS4fuAruLmyc1zQab2cd+YRfF98S4BupoTVz+A= // @connect pdfnovels.net // @grant GM_getValue // @grant GM_setValue From 03ba116584151d94b76f3e339a78da76c7e62492 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:36:35 +0800 Subject: [PATCH 0626/1027] v7.6 --- RawMangaAssistant.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RawMangaAssistant.user.js b/RawMangaAssistant.user.js index e5c8e72..3ed66dc 100644 --- a/RawMangaAssistant.user.js +++ b/RawMangaAssistant.user.js @@ -17,8 +17,8 @@ // @connect * // @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/notify.js#sha256-Cras2dh1/vJid5qUF5zZmNlt7hXmYpC9kQEZ+5yY5cM= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/lib/aria2.js#sha256-3mm3pLgUtNGzHaFHvoclOtHCz+K6juHsJfNAIor+6n8= -// @require https://raw.githubusercontent.com/jc3213/jslib/main/lib/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/js/aria2.js#sha256-3mm3pLgUtNGzHaFHvoclOtHCz+K6juHsJfNAIor+6n8= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/js/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest From 166debce3a05530c6eb7d4650b195c71b317fe17 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:37:37 +0800 Subject: [PATCH 0627/1027] v3.7: update lib --- SpeedRunHelper.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SpeedRunHelper.user.js b/SpeedRunHelper.user.js index 0212b8b..cc2b3be 100644 --- a/SpeedRunHelper.user.js +++ b/SpeedRunHelper.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @name Speedrun.com Helper // @namespace https://github.com/jc3213/userscript -// @version 3.6 +// @version 3.7 // @description Easy way for speedrun.com to open record window // @author jc3213 // @match *://www.speedrun.com/* -// @require https://raw.githubusercontent.com/jc3213/jslib/main/src/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/js/draggable.js#sha256-ttGznYlzdVyciXIQQ63rO0vKhx6OfpuvdCDkBFF2AcI= // @grant GM_webRequest // @webRequest {"selector": "*.hotjar.com/*", "action": "cancel"} // @webRequest {"selector": "*.stripe.com/*", "action": "cancel"} From 65399d792df9c48f3cd4a6e8c558006fd70fc533 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:38:26 +0800 Subject: [PATCH 0628/1027] v4.8: update libs --- BilibiliLiveRoomFilter.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 024788b..881da4d 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -2,13 +2,13 @@ // @name Bilibili Liveroom Filter // @name:zh 哔哩哔哩直播间屏蔽工具 // @namespace https://github.com/jc3213/userscript -// @version 4.7 +// @version 4.8 // @description Filtering Bilibili liveroom, batch management, export, import rulelist... // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jsui/main/ui/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= // @grant GM_getValue // @grant GM_setValue // @noframes From 1accf9522778cfb00f9842925f1246f579826a0d Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:39:12 +0800 Subject: [PATCH 0629/1027] v4.8 --- BilibiliLiveRoomFilter.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BilibiliLiveRoomFilter.user.js b/BilibiliLiveRoomFilter.user.js index 881da4d..765d045 100644 --- a/BilibiliLiveRoomFilter.user.js +++ b/BilibiliLiveRoomFilter.user.js @@ -7,8 +7,8 @@ // @description:zh 哔哩哔哩直播间屏蔽工具,支持管理列表,批量屏蔽,导出、导入列表等…… // @author jc3213 // @match *://live.bilibili.com/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= -// @require https://raw.githubusercontent.com/jc3213/jsui/main/ui/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/table.js#sha256-he3P3lqMaUzv58vquTVe3Rvy3pf1fi+ZeSZqCg2c9mQ= // @grant GM_getValue // @grant GM_setValue // @noframes From 553dd5429d49d235acc078dcd97636a7c7c9c631 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 20:39:35 +0800 Subject: [PATCH 0630/1027] v3.17: update lib --- BilibiliVideoDownloader.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BilibiliVideoDownloader.user.js b/BilibiliVideoDownloader.user.js index 35e582a..afb4980 100644 --- a/BilibiliVideoDownloader.user.js +++ b/BilibiliVideoDownloader.user.js @@ -2,12 +2,12 @@ // @name Bilibili Video Downloader // @name:zh 哔哩哔哩视频下载器 // @namespace https://github.com/jc3213/userscript -// @version 3.16 +// @version 3.17 // @description Download videos from Bilibili (No Bangumi) // @description:zh 下载哔哩哔哩视频(不支持番剧) // @author jc3213 // @match *://www.bilibili.com/video/* -// @require https://raw.githubusercontent.com/jc3213/jsui/main/src/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @run-at document-end // ==/UserScript== From e8f432b1626ebb37f409fa8297c845d849a90e62 Mon Sep 17 00:00:00 2001 From: jc3213 Date: Wed, 21 Sep 2022 21:40:12 +0800 Subject: [PATCH 0631/1027] better logic --- tsdmAutoSignAndWork.user.js | 138 ++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 61 deletions(-) diff --git a/tsdmAutoSignAndWork.user.js b/tsdmAutoSignAndWork.user.js index 39cdb58..bee520a 100644 --- a/tsdmAutoSignAndWork.user.js +++ b/tsdmAutoSignAndWork.user.js @@ -1,113 +1,129 @@ // ==UserScript== // @name 天使动漫自动签到打工 // @namespace https://github.com/jc3213/userscript -// @version 3.3 +// @version 3.6 // @description 天使动漫全自动打工签到脚本 — 完全自动无需任何操作,只需静待一分钟左右 // @author jc3213 // @match *://www.tsdm39.net/* -// @grant GM_getValue -// @grant GM_setValue +// @require https://raw.githubusercontent.com/jc3213/jslib/main/ui/menu.js#sha256-DsH2PJCMq/NhU59epDuDnAZ9CSGYy+059t0xZ/0N98Q= // @noframes // ==/UserScript== 'use strict'; -var signed = GM_getValue('signed', 0); -var worked = GM_getValue('worked', 0); -var autoed = GM_getValue('autoed', false); -var today = new Date().getFullYear() + new Date().getMonth() + new Date().getDate(); -var now = Date.now(); +var {signed = '0', worked = '0', autorun = '0'} = localStorage; +var working = {}; +var today = new Date(); +var date = today.getFullYear() + today.getMonth() + today.getDate(); +var now = today.getTime(); +var jsMenu = new JSUI_Menu(); -var css = document.createElement('style'); -css.innerHTML = '.my-menu {background-color: #fff; position: fixed; top: 40px; right: 100px; width: 100px; z-index: 99999;}\ -.my-menu button {width: 100px; padding: 5px;}\ -iframe {position: absolute; top: 200px; left: 100px; height: 800px; width: 800px; display: none;}'; +var smenu = jsMenu.menu([ + {label: '签到', onclick: autoSign}, + {label: '打工', onclick: autoWork}, + {label: '自动', onclick: switchAuto} +]); +var autoBtn = smenu.childNodes[2]; +autoBtn.innerText = autorun === '1' ? '✅自动' : '自动'; -var menu = document.createElement('div'); -menu.innerHTML = '\ -\ -'; -menu.className = 'my-menu'; -menu.querySelector('.my-auto').innerHTML = autoed ? '✅' : ''; +var css = document.createElement('style'); +css.innerHTML = '.jsui_basic_menu {width: 180px;}\ +.jsui_menu_btn {font-weight: bold; border-radius: 5px; background-color: #000; padding: 2px 10px; margin: 4px 0px;}\ +.jsui_menu_btn:last-child {flex: 1.5;}\ +iframe {position: absolute; top: 200px; left: 100px; height: 400px; width: 400px; display: none;}'; -document.body.append(menu, css); +var headbar = document.querySelector('#toptb > .wp'); +headbar.append(smenu, css); -if (autoed) { +if (autorun === '1') { today > signed && autoSign(); now > worked ? autoWork() : setTimeout(autoWork, worked - now); } -menu.querySelector('.my-button:nth-child(1)').addEventListener('click', autoSign); -menu.querySelector('.my-button:nth-child(2)').addEventListener('click', autoWork); -menu.querySelector('.my-button:nth-child(3)').addEventListener('click', event => { - autoed = !autoed; - menu.querySelector('.my-auto').innerHTML = autoed ? '✅' : ''; - GM_setValue('autoed', autoed); -}); +function switchAuto() { + localStorage.autorun = autorun = autorun === '1' ? '0' : '1'; + autoBtn.innerText = autorun === '1' ? '✅自动' : '自动'; +} async function autoSign() { - var {warn, window, document} = await startWork('/plugin.php?id=dsu_paulsign:sign'); - if (document.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)')) { - GM_setValue('signed', today); - warn.innerText = document.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)').innerText; - endWork(window, warn); + if (working.sign) { + return; + } + working.sign = now; + var popup = startPopup('查询签到状态...', '80px'); + var idoc = await startWork('/plugin.php?id=dsu_paulsign:sign'); + var iwin = idoc.defaultView; + if (idoc.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)')) { + localStorage.signed = signed = today; + popup.innerText = idoc.querySelector('#ct_shell > div:nth-child(1) > h1:nth-child(1)').innerText; + endWork(iwin, popup, 'sign'); } else { - warn.innerText = '开始签到...'; - window.Icon_selected('kx'); - document.getElementById('todaysay').value = '每日签到'; + popup.innerText = '开始签到...'; + iwin.Icon_selected('kx'); + idoc.getElementById('todaysay').value = '每日签到'; setTimeout(() => { - window.showWindow('qwindow', 'qiandao', 'post', '0'); - GM_setValue('signed', today); - warn.innerText = '已完成签到'; - endWork(window, warn); + iwin.showWindow('qwindow', 'qiandao', 'post', '0'); + localStorage.signed = signed = today; + popup.innerText = '已完成签到'; + endWork(iwin, popup, 'sign'); }, 3000); } } async function autoWork() { - var {warn, window, document} = await startWork('/plugin.php?id=np_cliworkdz:work'); - if (document.querySelector('#messagetext')) { - var text = document.querySelector('#messagetext > p:nth-child(1)').innerHTML.split(/
                                      |