Skip to content

Commit

Permalink
Fixed Music Pages CORS Error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangboheng committed Jan 27, 2023
1 parent d75c22a commit 84d9fae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
10 changes: 7 additions & 3 deletions js/music.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var channels = [];
var plyist = [];
var proxy = {
0: 'https://cors.luckydesigner.workers.dev/?',
1: 'https://bird.ioliu.cn/v1?url=',
};
//Get default localstorage key
var localkey = ['manga', 'bannedcountries', 'novel', 'movie', 'music', 'languages', 'porn', 'adult'];
$(document).ready(function () {
Expand All @@ -10,7 +14,7 @@ $(document).ready(function () {
var player = videojs(document.querySelector('#video1'));
$.ajax({
type: "GET",
url: `https://api-music.imsyy.top/artist/songs?id=${ids}`,
url: proxy[0] + `https://api-music.imsyy.top/artist/songs?id=${ids}`,
data: {
limit: 100
},
Expand Down Expand Up @@ -242,12 +246,12 @@ function audioPlay(ids) {
var player = videojs(document.querySelector('#video1'));
//Test muisc if is invalid
$.ajax({
url: 'https://api-music.imsyy.top' + '/check/music?id=' + ids,
url: proxy[0] + 'https://api-music.imsyy.top' + '/check/music?id=' + ids,
type: "GET",
dataType: "json",
success: function (data) {
$.ajax({
url: 'https://api-music.imsyy.top' + '/song/url?id=' + ids,
url: proxy[0] + 'https://api-music.imsyy.top' + '/song/url?id=' + ids,
type: "GET",
dataType: "json",
success: function (data) {
Expand Down
14 changes: 7 additions & 7 deletions js/tomusic.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ $(document).ready(function() {
pnum++;
if (link == 'https://api-music.imsyy.top/') {
if (sts.length > 0) {
globallink = link + 'search?keywords=' + sts + `&limit=20&offset=${20*pnum - 20}`;
globallink = proxy[0] + link + 'search?keywords=' + sts + `&limit=20&offset=${20*pnum - 20}`;
} else {
str = str == "0" ? link + `artist/list?type=-1&area=-1&limit=20&offset=${20*pnum - 20}` : str + `&limit=20&offset=${20*pnum - 20}`;
globallink = str;
}
$.ajax({
url: globallink,
url: proxy[0] + globallink,
type: "GET",
dataType: "json",
success: function(data) {
Expand Down Expand Up @@ -207,7 +207,7 @@ function iniMenu(link) {
$(this).addClass("bd").siblings().removeClass("bd");
});
$.ajax({
url: link + 'artist/list',
url: proxy[0] + link + 'artist/list',
data: {
type: '-1',
area: '-1',
Expand Down Expand Up @@ -272,7 +272,7 @@ function iniMenu(link) {
var valThis = $(this).val().toLowerCase();
searchlink = `${link + 'search?keywords=' + valThis}`;
$.ajax({
url: searchlink,
url: proxy[0] + searchlink,
data: {
limit: 20,
},
Expand Down Expand Up @@ -350,7 +350,7 @@ function iniMenu(link) {
$('#search').val('');
$('#root').append(`<div class="loadingimg"><img src="../images/loading.gif" tag="Easy Web TV"></div>`);
$.ajax({
url: className,
url: proxy[0] + className,
data: {
limit: 20
},
Expand Down Expand Up @@ -416,12 +416,12 @@ function iniMenu(link) {
function audioPlay(ids) {
//Test muisc if is invalid
$.ajax({
url: 'https://api-music.imsyy.top' + '/check/music?id=' + ids,
url: proxy[0] + 'https://api-music.imsyy.top' + '/check/music?id=' + ids,
type: "GET",
dataType: "json",
success: function(data) {
$.ajax({
url: 'https://api-music.imsyy.top' + '/song/url?id=' + ids,
url: proxy[0] + 'https://api-music.imsyy.top' + '/song/url?id=' + ids,
type: "GET",
dataType: "json",
success: function(data) {
Expand Down

0 comments on commit 84d9fae

Please sign in to comment.