Skip to content

Commit

Permalink
2.6.0/1 : Ughh
Browse files Browse the repository at this point in the history
  • Loading branch information
Banderi committed Aug 1, 2024
1 parent 16f096c commit 44e94db
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.zip
*.xpi
*.bat
56 changes: 53 additions & 3 deletions ext/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function isDevMode() {
return !('update_url' in browser.runtime.getManifest());
}

var motd = "The final update... (?)";
var motd = "I lied.";

var livecount = 0;
var invitecount = 0;
Expand Down Expand Up @@ -487,8 +487,59 @@ function fetch_from_cookies() {
} // failure callback
);
}
function fetch_channel_data(auth_bear) {
async function fetch_channel_data(auth_bear) {
// Upstream API
$.ajax({
url: "https://api.picarto.tv/api/v1/online",
type:"GET",
contentType:"application/json; charset=utf-8",
beforeSend: function (xhr) {
xhr.setRequestHeader('authorization', auth_bear);
},
dataType:"json",
success: function(online_list) {

// create a new Promise objecy to have an async block here because jQuery ($.ajax) does not readily support async callbacks.
return new Promise(async(resolve, reject)=>{
exploreData = [];
for (i in online_list) {
let channelData = online_list[i];
if (channelData.following) {

let avatar_url = "";
await $.ajax({
url: "https://api.picarto.tv/api/v1/channel/id/" + channelData.user_id,
type:"GET",
contentType:"application/json; charset=utf-8",
beforeSend: function (xhr) {
xhr.setRequestHeader('authorization', auth_bear);
},
dataType:"json",
success: function(channel_info) { avatar_url = channel_info.avatar; },
error: function(data) { if (isDevMode()) console.log(data); }
});

exploreData.push({
"channel_name": channelData.name,
"avatar": avatar_url
})
}
}

updateLive(()=>{
/* updateAPI(()=>{ */
updateBadge(()=>{
updateMOTD(); // done!
})
/* }) */
})
});
},
error: function(data) { if (isDevMode()) console.log(data); }
});
return;

// Old API seemingly does not work anymore.
let querytosend = {
query: "query ($first: Int!, $page: Int!, $q: String) {\n following(first: $first, page: $page, q: $q, orderBy: {field: \"last_live\", order: DESC}) {\n account_type\n avatar\n channel_name\n id\n last_live\n online\n __typename\n }\n}\n",
variables: {
Expand All @@ -497,7 +548,6 @@ function fetch_channel_data(auth_bear) {
"q": ""
}
}

$.ajax({
url: "https://ptvintern.picarto.tv/ptvapi",
type:"POST",
Expand Down
6 changes: 3 additions & 3 deletions ext/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Picarto Notifier",
"version": "2.5.1",
"version": "2.6.1",
"manifest_version": 2,
"permissions": [
"*://*.picarto.tv/*",
Expand Down Expand Up @@ -46,8 +46,8 @@
},
"applications": {
"gecko": {
"id": "myextension@mydomain.com",
"strict_min_version": "42.0"
"id": "myextension_signed@mydomain.com",
"strict_min_version": "58.0"
}
}
}

0 comments on commit 44e94db

Please sign in to comment.