dlsite跳转放流资源
当前为
// ==UserScript==
// @name dlsite jump
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @license MIT
// @description dlsite跳转放流资源
// @author crudBoy
// @match https://*.dlsite.com/*/product_id/*
// @icon https://www.dlsite.com/images/web/common/logo/pc/logo-dlsite.png
// @grant GM_xmlhttpRequest
// @connect asmr-200.com
// @connect erovoice.us
// @connect anime-sharing.com
// ==/UserScript==
((o) => {
if (typeof GM_addStyle == "function") {
GM_addStyle(o);
return;
}
const t = document.createElement("style");
(t.textContent = o), document.head.append(t);
})(
" .rdl-list{box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:flex-start;gap:10px;width:100%;height:100%;z-index:1;background-color:#fff;transition:right .2s ease-in-out;font-family:Roboto,Helvetica,Arial,sans-serif;color:#000}.rdl-button,.rdl-button_def{position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;padding:3px 10px;border-radius:4px;font-weight:500;font-size:14px;border:1px solid #dcdfe6;color:#606266;cursor:pointer}.rdl-button_def{margin:10px 0;width:100px}.rdl-button:visited{color:#606266}.rdl-button:hover{text-decoration:none;color:#409eff;border:1px solid #c6e2ff;background-color:#ecf5ff}.rdl-button_label{position:absolute;font-size:10px;padding:4px;border-radius:4px;top:-13px;right:-10px;line-height:.75;color:#67c23a;border:1px solid #e1f3d8;background:white}.rdl-button_green{color:#fff!important;background-color:#67c23a}.rdl-button_green:hover{color:#fff!important;background-color:#95d475}.rdl-button_red{color:#fff!important;background-color:#f56c6c}.rdl-button_red:hover{color:#fff!important;background-color:#f89898}.rdl-loading{display:inline-block;width:14px;height:14px;margin-right:10px;border:2px dashed #dcdfe6;border-top-color:transparent;border-radius:100%;animation:btnLoading infinite 1s linear}@keyframes btnLoading{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.rdl-tag{padding:3px 6px;color:#409eff!important;background:#ecf5ff;border:1px solid #d9ecff;border-radius:4px}.rdl-setting-list{display:flex;flex-wrap:wrap;background-color:#fff}.rdl-setting-title{margin:10px 0 5px}.rdl-setting-item{display:flex;height:20px;justify-content:center;align-items:center;margin-right:15px;-webkit-user-select:none;user-select:none;cursor:pointer}.db-panel .movie-panel-info div.panel-block{padding:5.5px 12px}.db-panel .rdl-app{padding:15px 12px}.lib-panel .rdl-app{padding:20px 30px;margin-top:10px}input[type=checkbox],input[type=radio]{margin:0 0 0 5px;cursor:pointer} ",
);
(function () {
'use strict';
initView()
function initView() {
let workOutline = document.getElementById("work_outline");
let body = workOutline.children[0]
let isAsmr = body.innerHTML.includes("icon_SOU");
let tr = document.createElement('tr');
let th = document.createElement('th');
th.textContent = "跳转"
let td = document.createElement('td');
let rdlApp = document.createElement("div")
rdlApp.className = "rdl-app"
let rdlList = document.createElement("div")
rdlList.className = "rdl-list"
const siteItems = [
{"title": "asmrone", "onlyAsmr": true},
{"title": "animeShare", "onlyAsmr": false},
{"title": "eroVoice", "onlyAsmr": true},
];
for (let item of siteItems) {
if (isAsmr || (!item.onlyAsmr)) {
let element = document.createElement("a");
element.className = "rdl-button";
element.target = "_blank";
let span = document.createElement("span");
span.innerText = item.title;
element.appendChild(span);
rdlList.appendChild(element);
}
}
rdlApp.appendChild(rdlList)
td.appendChild(rdlApp)
tr.appendChild(th)
tr.appendChild(td)
body.appendChild(tr)
checkExits(isAsmr)
}
function findItem(t) {
let list = document.getElementsByClassName("rdl-list")[0]
for (let i = 0; i < list.children.length; i++) {
let item = list.children[i]
if (item.textContent === t) {
return item
}
}
return null
}
function checkExits(isAsmr) {
let rj = urlToRJNumber(document.URL)
if (isAsmr) {
asmrOneCheck(rj)
eroVoiceCheck(rj)
}
animeShareCheck(rj)
}
function asmrOneCheck(rj) {
let url =
"https://api.asmr-200.com/api/search/" + rj + "?order=create_date&sort=desc&page=1&subtitle=0&includeTranslationWorks=true"
let item = findItem("asmrone");
fetchData(url)
.then(response => {
let works = JSON.parse(response.responseText).works
if (works.length > 1) {
item.className = "rdl-button rdl-button_green"
item.href = "https://asmr-200.com/works?keyword=" + rj
} else if (works.length === 1) {
item.className = "rdl-button rdl-button_green"
item.href = "https://asmr-200.com/work/" + rj
} else {
item.className = "rdl-button rdl-button_red"
}
})
.catch(error => {
console.log(error);
item.className = "rdl-button rdl-button_red "
});
}
function eroVoiceCheck(rj) {
let url =
"https://e.erovoice.us/search/?q=" + rj
let item = findItem("eroVoice");
fetchData(url)
.then(response => {
let parser = new DOMParser();
let doc = parser.parseFromString(response.responseText, 'text/html');
let dateOuter = doc.getElementsByClassName("date-outer")
if (dateOuter.length > 1) {
item.className = "rdl-button rdl-button_green"
item.href = url
} else if (dateOuter.length === 1) {
item.className = "rdl-button rdl-button_green"
item.href = doc.getElementsByClassName("anes")[0].href
} else {
item.className = "rdl-button rdl-button_red"
}
})
.catch(error => {
console.log(error);
item.className = "rdl-button rdl-button_red "
});
}
function animeShareCheck(rj) {
let url =
"https://www.anime-sharing.com/search/3528560/?q=" + rj + "&o=relevance"
let item = findItem("animeShare");
fetchData(url)
.then(response => {
let parser = new DOMParser();
let doc = parser.parseFromString(response.responseText, 'text/html');
let voiceIconNode = doc.getElementsByClassName("label label--primary")
if (voiceIconNode.length > 0 && doc.getElementsByClassName("query-replacement").length < 1) {
item.className = "rdl-button rdl-button_green"
item.href = url
} else {
item.className = "rdl-button rdl-button_red"
}
})
.catch(error => {
console.log(error);
item.className = "rdl-button rdl-button_red "
});
}
function fetchData(url) {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: (response) => resolve(response),
onerror: (error) => reject(error),
});
});
}
function urlToRJNumber(url) {
let rjCode = ""
if (url.includes("?")) {
rjCode = url.substring(url.lastIndexOf("translation=") + 12)
} else {
rjCode = url.substring(url.lastIndexOf("/") + 1, url.lastIndexOf("."))
}
return rjCode
}
})();