Pixelfed compat

This commit is contained in:
cutls 2019-10-14 00:28:44 +09:00
parent 85468761d3
commit 6b339b636a
4 changed files with 27 additions and 16 deletions

View File

@ -302,6 +302,9 @@ function login(url) {
$("#compt").hide() $("#compt").hide()
if ($('#linux:checked').val() == "on") { if ($('#linux:checked').val() == "on") {
var red = "urn:ietf:wg:oauth:2.0:oob" var red = "urn:ietf:wg:oauth:2.0:oob"
if(~url.indexOf("pixelfed")){
red = "https://thedesk.top/hello.html"
}
} else { } else {
var red = 'thedesk://manager'; var red = 'thedesk://manager';
} }
@ -352,15 +355,14 @@ function versionChecker(url) {
}).then(function (json) { }).then(function (json) {
var version = json.version var version = json.version
if (version) { if (version) {
var reg = version.match(/^[0-9]\.[0-9]\.[0-9]/u); var reg = version.match(/^([0-9])\.[0-9]\.[0-9]/u);
if (reg) { if (reg) {
reg = reg[0] versionCompat(reg[1], reg, json.title, reg[0])
versionCompat(url, reg, json.title, version)
} }
} }
}); });
} }
function versionCompat(url, ver, title, real) { function versionCompat(prefix, ver, title, real) {
$("#compt-instance").text(title) $("#compt-instance").text(title)
$("#compt-ver").text(real) $("#compt-ver").text(real)
if(~real.indexOf("compatible")){ if(~real.indexOf("compatible")){
@ -383,10 +385,13 @@ function versionCompat(url, ver, title, real) {
}).then(function (json) { }).then(function (json) {
var complete = false var complete = false
var ct = 0 var ct = 0
var jl = 0
var jl2 = 0
Object.keys(json).forEach(function (key) { Object.keys(json).forEach(function (key) {
var data = json[key]; var data = json[key];
if (data) { if (data) {
if (key != ver && !complete) { jl++
if (key != real && !complete) {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
var e = "" var e = ""
if (i == 0) { if (i == 0) {
@ -396,15 +401,17 @@ function versionCompat(url, ver, title, real) {
ct++; ct++;
e = "" e = ""
} }
jl2++
} else if (!complete) { } else if (!complete) {
complete = true complete = true
} }
} }
var lastkey = key
}); });
if (lang.language == "ja" && ct > 0) { if(lang.language == "ja" && ct > 0){
if (jl2!=jl && prefix!="1") {
$("#compt").show() $("#compt").show()
} }
}
}); });
} }
@ -566,6 +573,10 @@ function code(code) {
} }
return; return;
} else { } else {
var red = "urn:ietf:wg:oauth:2.0:oob"
if(~url.indexOf("pixelfed")){
red = "https://thedesk.top/hello.html"
}
var start = "https://" + url + "/oauth/token"; var start = "https://" + url + "/oauth/token";
var id = localStorage.getItem("client_id"); var id = localStorage.getItem("client_id");
var secret = localStorage.getItem("client_secret"); var secret = localStorage.getItem("client_secret");
@ -575,7 +586,7 @@ function code(code) {
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ httpreq.send(JSON.stringify({
grant_type: "authorization_code", grant_type: "authorization_code",
redirect_uri: "urn:ietf:wg:oauth:2.0:oob", redirect_uri: red,
client_id: id, client_id: id,
client_secret: secret, client_secret: secret,
code: code code: code

View File

@ -18,12 +18,12 @@ $(document).on('click', 'a', e => {
//タグのURLぽかったら //タグのURLぽかったら
var tags = []; var tags = [];
tags = url.match( tags = url.match(
/https:\/\/([^+_]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\&=+\$,%#]+)/ /https:\/\/([^+_]+)\/tags\/([_a-zA-Z0-9\&=+\%]+)/
); );
//メンションっぽかったら //メンションっぽかったら
var ats = []; var ats = [];
ats = url.match( ats = url.match(
/https:\/\/([^+_]+)\/@([-_.!~*\'()a-zA-Z0-9;\/?:\&=+\$,%#@]+)/ /https:\/\/([^+_]+)\/@([_a-zA-Z0-9\&=+\%]+)/
); );
if (toot) { if (toot) {
if (toot[1]) { if (toot[1]) {

File diff suppressed because one or more lines are too long

View File

@ -56,7 +56,6 @@
"jquery-ui-dist": "^1.12.1", "jquery-ui-dist": "^1.12.1",
"json5": "^2.1.1", "json5": "^2.1.1",
"materialize-css": "^1.0.0", "materialize-css": "^1.0.0",
"node-notifier": "^6.0.0",
"sumchecker": "^3.0.0", "sumchecker": "^3.0.0",
"sweetalert2": "^8.18.3", "sweetalert2": "^8.18.3",
"vue": "^2.6.10" "vue": "^2.6.10"