Skip to content

Commit

Permalink
修复pornhub链接失效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lovevol committed Jun 18, 2021
1 parent fc38395 commit 6cb3a47
Showing 1 changed file with 50 additions and 8 deletions.
58 changes: 50 additions & 8 deletions js/pornhubInject.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
document.getElementById('mySuperDownload').addEventListener('click', function () {
let quality_240p = "无"
let quality_480p = "无"
let quality_720p = "无"
let quality_1080p = "无"

document.getElementById('mySuperDownload').addEventListener('click', async function () {
$("#mySuperDownloadArea").toggle()
let itemId = WIDGET_RATINGS_LIKE_FAV.itemId
let flashvarsId = "flashvars_" + itemId;
let flashvarsObject = eval(flashvarsId)
let quality_1080p = flashvarsObject.quality_1080p || "无"
let quality_720p = flashvarsObject.quality_720p || "无"
let quality_240p = flashvarsObject.quality_240p || "无"
let quality_480p = flashvarsObject.quality_480p || "无"
let videoTitle = flashvarsObject.video_title
let html = document.getElementById("mySuperDownloadArea").innerHTML
html = "";
let getMediaUrl = ""
$.each(flashvarsObject.mediaDefinitions, function (i, item) {
if (item.format == 'mp4') {
getMediaUrl = item.videoUrl
}
})
// 异步调用
await getVideoUrl(getMediaUrl)
let html = "";
let child = `
<div>
<ul>
Expand All @@ -28,3 +35,38 @@ function copyUrl(id) {
Url2.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
}

function getVideoUrl(getMediaUrl) {
var p = new Promise(function (resolve, reject) { //做一些异步操作
$.ajax({
type: "GET",
url: getMediaUrl,
success: function (data, status) {
if (status == "success") {
$.each(data, function (i, item) {
if (item.quality == '240') {
quality_240p = item.videoUrl
}
if (item.quality == '480') {
quality_480p = item.videoUrl
}
if (item.quality == '720') {
quality_720p = item.videoUrl
}
if (item.quality == '1080') {
quality_1080p = item.videoUrl
}
});
resolve("通讯结束!")
}
},
error: function (xhr, errorText, errorType) {
},
complete: function () {
//do something
}
})
});
return p;
}

0 comments on commit 6cb3a47

Please sign in to comment.