Skip to content

Commit dfc791c

Browse files
committed
Reinstated Akinator with 3rd party CORS (might not last long)
1 parent 9786937 commit dfc791c

2 files changed

Lines changed: 9 additions & 76 deletions

File tree

‎akinator.html‎

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,6 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
449449
var backButton = document.getElementById('back-btn');
450450
var resultPhoto = document.getElementById('result-photo');
451451

452-
var API_BASE = 'https://rekindle-akinator.timjarnott.workers.dev';
453-
454452
var CORS_PROXIES = [
455453
{ base: 'https://test.cors.workers.dev/?', encode: false },
456454
{ base: 'https://corsproxy.io/?url=', encode: true },
@@ -590,50 +588,7 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
590588
return data;
591589
}
592590

593-
async function startViaWorker() {
594-
var res = await fetchWithTimeout(API_BASE + '/start', {
595-
method: 'POST',
596-
headers: { 'Content-Type': 'application/json' },
597-
body: JSON.stringify({ region: state.region, childMode: state.childMode })
598-
}, 15000);
599-
var data = await res.json().catch(function () { return null; });
600-
if (!data || typeof data !== 'object') {
601-
throw new Error(translate('akinator.error.network', 'Network error. Please try again.'));
602-
}
603-
if (!res.ok || data.error) {
604-
throw new Error(data.error || translate('akinator.error.network', 'Network error. Please try again.'));
605-
}
606-
return data;
607-
}
608-
609-
async function actionViaWorker(path, params) {
610-
var body = {
611-
region: state.region,
612-
childMode: state.childMode,
613-
session: state.session,
614-
signature: state.signature
615-
};
616-
for (var key in params) {
617-
if (Object.prototype.hasOwnProperty.call(params, key)) body[key] = params[key];
618-
}
619-
var res = await fetchWithTimeout(API_BASE + path, {
620-
method: 'POST',
621-
headers: { 'Content-Type': 'application/json' },
622-
body: JSON.stringify(body)
623-
}, 15000);
624-
var data = await res.json().catch(function () { return null; });
625-
if (!data || typeof data !== 'object') {
626-
throw new Error(translate('akinator.error.network', 'Network error. Please try again.'));
627-
}
628-
if (!res.ok || data.error) {
629-
throw new Error(data.error || translate('akinator.error.network', 'Network error. Please try again.'));
630-
}
631-
return data;
632-
}
633-
634591
function sameTransport(a, b) {
635-
if (a.type !== b.type) return false;
636-
if (a.type === 'worker') return true;
637592
return a.proxy.base === b.proxy.base;
638593
}
639594

@@ -643,7 +598,6 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
643598
for (i = 0; i < CORS_PROXIES.length; i++) {
644599
list.push({ type: 'proxy', proxy: CORS_PROXIES[i] });
645600
}
646-
list.push({ type: 'worker' });
647601
if (activeTransport) {
648602
for (i = 0; i < list.length; i++) {
649603
if (sameTransport(list[i], activeTransport)) {
@@ -677,7 +631,7 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
677631

678632
function apiStart() {
679633
return withTransport(function (t) {
680-
var p = t.type === 'worker' ? startViaWorker() : startViaProxy(t.proxy);
634+
var p = startViaProxy(t.proxy);
681635
return p.then(function (data) {
682636
if (!data || !data.session || !data.signature || !data.question) {
683637
throw new Error('Invalid start response');
@@ -689,14 +643,6 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
689643

690644
function apiAnswer(index) {
691645
return withTransport(function (t) {
692-
if (t.type === 'worker') {
693-
return actionViaWorker('/answer', {
694-
step: state.step,
695-
progression: state.progression,
696-
answer: index,
697-
stepLast: state.stepLast
698-
});
699-
}
700646
var info = regionInfo(state.region);
701647
return actionViaProxy(t.proxy, '/answer', {
702648
step: state.step,
@@ -713,12 +659,6 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
713659

714660
function apiBack() {
715661
return withTransport(function (t) {
716-
if (t.type === 'worker') {
717-
return actionViaWorker('/back', {
718-
step: state.step,
719-
progression: state.progression
720-
});
721-
}
722662
var info = regionInfo(state.region);
723663
return actionViaProxy(t.proxy, '/cancel_answer', {
724664
step: state.step,
@@ -733,13 +673,6 @@ <h2 style="text-align: center; margin-top: 0;" data-i18n="akinator.result.thinki
733673

734674
function apiContinue() {
735675
return withTransport(function (t) {
736-
if (t.type === 'worker') {
737-
return actionViaWorker('/continue', {
738-
step: state.step,
739-
progression: state.progression,
740-
stepLast: state.stepLast
741-
});
742-
}
743676
var info = regionInfo(state.region);
744677
return actionViaProxy(t.proxy, '/exclude', {
745678
step: state.step,

‎icons.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,14 @@ const APPS = [
519519
cat: 'games',
520520
icon: '<rect x="2" y="2" width="28" height="28" fill="white" stroke="black" stroke-width="2"/><line x1="16" y1="2" x2="16" y2="30" stroke="black" stroke-width="2"/><line x1="2" y1="16" x2="30" y2="16" stroke="black" stroke-width="2"/><text x="9" y="13" font-size="10" text-anchor="middle" font-family="sans-serif" fill="black" stroke="none" font-weight="bold">2</text><text x="23" y="13" font-size="10" text-anchor="middle" font-family="sans-serif" fill="black" stroke="none" font-weight="bold">0</text><text x="9" y="27" font-size="10" text-anchor="middle" font-family="sans-serif" fill="black" stroke="none" font-weight="bold">4</text><text x="23" y="27" font-size="10" text-anchor="middle" font-family="sans-serif" fill="black" stroke="none" font-weight="bold">8</text>'
521521
},
522-
/* {
523-
id: 'akinator',
524-
name: 'Akinator',
525-
cat: 'games',
526-
desc: 'The genie guesses your character.',
527-
new: true,
528-
icon: '<g transform="scale(0.64)"><path d="M 38.5 5 C 34.921875 5 32 7.921875 32 11.5 C 32 13.394531 32.730469 14.890625 33.675781 15.925781 C 34.621094 16.964844 35.746094 17.582031 36.632813 17.929688 C 38.683594 18.738281 40.15625 19.371094 41.015625 19.90625 C 41.070313 19.941406 41.097656 19.96875 41.144531 20 L 40.171875 20 C 39.949219 20 39.734375 20.074219 39.5625 20.207031 C 37.570313 21.734375 33.492188 22.941406 28.78125 22.988281 C 27.578125 21.097656 25.996094 19.511719 24.21875 18.667969 C 24.699219 18.070313 25 17.320313 25 16.5 C 25 14.578125 23.421875 13 21.5 13 C 19.578125 13 18 14.578125 18 16.5 C 18 17.320313 18.300781 18.066406 18.78125 18.667969 C 16.882813 19.5625 15.214844 21.300781 13.984375 23.359375 C 13.128906 23.664063 12.359375 24.15625 11.734375 24.792969 C 11.714844 24.703125 11.714844 24.621094 11.691406 24.535156 C 11.457031 23.5 11.066406 22.417969 10.324219 21.53125 C 9.582031 20.644531 8.417969 20 7 20 C 5.230469 20 4.0625 21.066406 3.554688 22.03125 C 3.042969 23 3 23.945313 3 23.945313 L 3 24 C 3 25.707031 3.570313 27.097656 4.414063 28.179688 C 5.261719 29.261719 6.347656 30.054688 7.421875 30.816406 C 8.742188 31.746094 9.390625 32.605469 9.554688 32.921875 C 9.433594 32.957031 9.390625 33 9 33 C 8.640625 32.996094 8.304688 33.183594 8.121094 33.496094 C 7.941406 33.808594 7.941406 34.191406 8.121094 34.503906 C 8.304688 34.816406 8.640625 35.003906 9 35 C 9.816406 35 10.488281 34.910156 11.0625 34.46875 C 11.445313 34.175781 11.640625 33.683594 11.683594 33.203125 C 12.214844 33.839844 12.816406 34.390625 13.421875 34.816406 C 13.425781 34.820313 13.425781 34.820313 13.425781 34.816406 C 15.105469 36 17.132813 36.65625 19.621094 36.875 C 19.296875 37.246094 19.089844 37.707031 19.03125 38.21875 C 18.089844 38.378906 17.222656 38.628906 16.484375 38.96875 C 15.808594 39.28125 15.226563 39.664063 14.773438 40.15625 C 14.320313 40.648438 14 41.292969 14 42 L 14 43 L 29 43 L 29 42 C 29 41.292969 28.679688 40.648438 28.226563 40.15625 C 27.773438 39.664063 27.191406 39.28125 26.515625 38.96875 C 25.777344 38.628906 24.910156 38.378906 23.96875 38.21875 C 23.910156 37.714844 23.707031 37.257813 23.390625 36.890625 C 28.492188 36.371094 32.082031 33.824219 36.664063 29.746094 C 39.992188 26.785156 43.59375 23.019531 46.363281 21.933594 C 46.8125 21.757813 47.074219 21.285156 46.984375 20.8125 C 46.894531 20.339844 46.480469 20 46 20 L 45.90625 20 C 45.625 18.269531 44.589844 16.257813 42.136719 15.070313 C 41.980469 14.992188 41.84375 14.921875 41.6875 14.84375 C 42.609375 14.675781 43.457031 14.28125 44.035156 13.59375 L 44.070313 13.550781 L 44.101563 13.503906 C 44.574219 12.796875 44.863281 11.976563 44.960938 11.121094 C 45 10.824219 45 10.726563 45 10.5 C 45 7.472656 42.527344 5 39.5 5 Z M 38.5 7 L 39.5 7 C 41.453125 7 43 8.546875 43 10.5 C 43 10.464844 42.953125 11.039063 42.980469 10.859375 L 42.980469 10.875 L 42.976563 10.890625 C 42.917969 11.421875 42.726563 11.90625 42.464844 12.324219 C 42.109375 12.722656 41.59375 13 41 13 C 40.339844 13 39.773438 12.6875 39.402344 12.203125 C 39.152344 11.859375 39 11.453125 39 11 L 39 10 L 38 10 C 36.90625 10 36 10.90625 36 12 C 36 12.136719 36.015625 12.226563 36.027344 12.300781 C 36.113281 13.179688 36.601563 13.898438 37.191406 14.453125 C 37.785156 15.007813 38.503906 15.449219 39.269531 15.871094 L 39.273438 15.871094 C 39.914063 16.214844 40.59375 16.539063 41.257813 16.867188 L 41.261719 16.871094 L 41.265625 16.871094 C 42.992188 17.707031 43.53125 18.890625 43.753906 20 L 43.65625 20 C 43.566406 19.796875 43.574219 19.554688 43.4375 19.378906 C 43.089844 18.917969 42.628906 18.554688 42.078125 18.207031 C 40.96875 17.519531 39.441406 16.886719 37.367188 16.070313 C 36.699219 15.808594 35.824219 15.316406 35.15625 14.582031 C 34.488281 13.847656 34 12.898438 34 11.5 C 34 9 36 7 38.5 7 Z M 21.5 15 C 22.339844 15 23 15.660156 23 16.5 C 23 17.339844 22.339844 18 21.5 18 C 20.660156 18 20 17.339844 20 16.5 C 20 15.660156 20.660156 15 21.5 15 Z M 21.5 20 C 22.9375 20 24.621094 21.289063 26.074219 23 L 16.9375 23 C 18.390625 21.296875 20.0625 20 21.5 20 Z M 7 22 C 7.871094 22 8.355469 22.296875 8.789063 22.816406 C 9.226563 23.335938 9.550781 24.132813 9.742188 24.980469 C 10.128906 26.667969 10.003906 28.4375 10.003906 28.4375 C 9.992188 28.535156 9.996094 28.640625 10.015625 28.738281 C 10.011719 28.828125 10 28.914063 10 29 C 10 29.515625 10.089844 30.015625 10.226563 30.5 C 9.757813 30.066406 9.21875 29.636719 8.578125 29.183594 C 7.527344 28.445313 6.613281 27.738281 5.992188 26.945313 C 5.375 26.160156 5.011719 25.300781 5.007813 24.03125 C 5.007813 24.007813 5.046875 23.488281 5.320313 22.96875 C 5.601563 22.433594 5.9375 22 7 22 Z M 40.425781 22 L 42.378906 22 C 39.933594 23.8125 37.566406 26.269531 35.335938 28.253906 C 30.464844 32.589844 27.296875 34.796875 22.066406 34.984375 C 22.066406 34.980469 22.066406 34.980469 22.0625 34.984375 C 21.851563 34.992188 21.667969 35 21.5 35 C 21.546875 35 21.527344 35 21.441406 35 C 21.441406 34.996094 21.441406 34.996094 21.4375 35 C 21.417969 34.996094 21.398438 34.996094 21.375 34.996094 C 18.320313 34.96875 16.257813 34.363281 14.578125 33.183594 C 13.347656 32.316406 12 30.386719 12 29 C 12 27.28125 13.074219 25.832031 14.589844 25.265625 L 14.902344 25.175781 C 15.078125 25.125 15.246094 25.089844 15.410156 25.058594 C 15.605469 25.03125 15.796875 25 16 25 L 29.984375 25 L 29.964844 24.957031 C 34.296875 24.761719 38.023438 23.695313 40.425781 22 Z M 21.5 40 C 21.925781 40 22.339844 40.023438 22.742188 40.0625 C 23.90625 40.175781 24.933594 40.445313 25.675781 40.785156 C 25.824219 40.855469 25.871094 40.929688 25.996094 41 L 17.003906 41 C 17.128906 40.929688 17.175781 40.855469 17.324219 40.785156 C 18.066406 40.445313 19.09375 40.175781 20.257813 40.0625 C 20.660156 40.023438 21.074219 40 21.5 40 Z"/></g>'
529-
}, */
522+
{
523+
id: 'akinator',
524+
name: 'Akinator',
525+
cat: 'games',
526+
desc: 'The genie guesses your character.',
527+
new: true,
528+
icon: '<g transform="scale(0.64)"><path d="M 38.5 5 C 34.921875 5 32 7.921875 32 11.5 C 32 13.394531 32.730469 14.890625 33.675781 15.925781 C 34.621094 16.964844 35.746094 17.582031 36.632813 17.929688 C 38.683594 18.738281 40.15625 19.371094 41.015625 19.90625 C 41.070313 19.941406 41.097656 19.96875 41.144531 20 L 40.171875 20 C 39.949219 20 39.734375 20.074219 39.5625 20.207031 C 37.570313 21.734375 33.492188 22.941406 28.78125 22.988281 C 27.578125 21.097656 25.996094 19.511719 24.21875 18.667969 C 24.699219 18.070313 25 17.320313 25 16.5 C 25 14.578125 23.421875 13 21.5 13 C 19.578125 13 18 14.578125 18 16.5 C 18 17.320313 18.300781 18.066406 18.78125 18.667969 C 16.882813 19.5625 15.214844 21.300781 13.984375 23.359375 C 13.128906 23.664063 12.359375 24.15625 11.734375 24.792969 C 11.714844 24.703125 11.714844 24.621094 11.691406 24.535156 C 11.457031 23.5 11.066406 22.417969 10.324219 21.53125 C 9.582031 20.644531 8.417969 20 7 20 C 5.230469 20 4.0625 21.066406 3.554688 22.03125 C 3.042969 23 3 23.945313 3 23.945313 L 3 24 C 3 25.707031 3.570313 27.097656 4.414063 28.179688 C 5.261719 29.261719 6.347656 30.054688 7.421875 30.816406 C 8.742188 31.746094 9.390625 32.605469 9.554688 32.921875 C 9.433594 32.957031 9.390625 33 9 33 C 8.640625 32.996094 8.304688 33.183594 8.121094 33.496094 C 7.941406 33.808594 7.941406 34.191406 8.121094 34.503906 C 8.304688 34.816406 8.640625 35.003906 9 35 C 9.816406 35 10.488281 34.910156 11.0625 34.46875 C 11.445313 34.175781 11.640625 33.683594 11.683594 33.203125 C 12.214844 33.839844 12.816406 34.390625 13.421875 34.816406 C 13.425781 34.820313 13.425781 34.820313 13.425781 34.816406 C 15.105469 36 17.132813 36.65625 19.621094 36.875 C 19.296875 37.246094 19.089844 37.707031 19.03125 38.21875 C 18.089844 38.378906 17.222656 38.628906 16.484375 38.96875 C 15.808594 39.28125 15.226563 39.664063 14.773438 40.15625 C 14.320313 40.648438 14 41.292969 14 42 L 14 43 L 29 43 L 29 42 C 29 41.292969 28.679688 40.648438 28.226563 40.15625 C 27.773438 39.664063 27.191406 39.28125 26.515625 38.96875 C 25.777344 38.628906 24.910156 38.378906 23.96875 38.21875 C 23.910156 37.714844 23.707031 37.257813 23.390625 36.890625 C 28.492188 36.371094 32.082031 33.824219 36.664063 29.746094 C 39.992188 26.785156 43.59375 23.019531 46.363281 21.933594 C 46.8125 21.757813 47.074219 21.285156 46.984375 20.8125 C 46.894531 20.339844 46.480469 20 46 20 L 45.90625 20 C 45.625 18.269531 44.589844 16.257813 42.136719 15.070313 C 41.980469 14.992188 41.84375 14.921875 41.6875 14.84375 C 42.609375 14.675781 43.457031 14.28125 44.035156 13.59375 L 44.070313 13.550781 L 44.101563 13.503906 C 44.574219 12.796875 44.863281 11.976563 44.960938 11.121094 C 45 10.824219 45 10.726563 45 10.5 C 45 7.472656 42.527344 5 39.5 5 Z M 38.5 7 L 39.5 7 C 41.453125 7 43 8.546875 43 10.5 C 43 10.464844 42.953125 11.039063 42.980469 10.859375 L 42.980469 10.875 L 42.976563 10.890625 C 42.917969 11.421875 42.726563 11.90625 42.464844 12.324219 C 42.109375 12.722656 41.59375 13 41 13 C 40.339844 13 39.773438 12.6875 39.402344 12.203125 C 39.152344 11.859375 39 11.453125 39 11 L 39 10 L 38 10 C 36.90625 10 36 10.90625 36 12 C 36 12.136719 36.015625 12.226563 36.027344 12.300781 C 36.113281 13.179688 36.601563 13.898438 37.191406 14.453125 C 37.785156 15.007813 38.503906 15.449219 39.269531 15.871094 L 39.273438 15.871094 C 39.914063 16.214844 40.59375 16.539063 41.257813 16.867188 L 41.261719 16.871094 L 41.265625 16.871094 C 42.992188 17.707031 43.53125 18.890625 43.753906 20 L 43.65625 20 C 43.566406 19.796875 43.574219 19.554688 43.4375 19.378906 C 43.089844 18.917969 42.628906 18.554688 42.078125 18.207031 C 40.96875 17.519531 39.441406 16.886719 37.367188 16.070313 C 36.699219 15.808594 35.824219 15.316406 35.15625 14.582031 C 34.488281 13.847656 34 12.898438 34 11.5 C 34 9 36 7 38.5 7 Z M 21.5 15 C 22.339844 15 23 15.660156 23 16.5 C 23 17.339844 22.339844 18 21.5 18 C 20.660156 18 20 17.339844 20 16.5 C 20 15.660156 20.660156 15 21.5 15 Z M 21.5 20 C 22.9375 20 24.621094 21.289063 26.074219 23 L 16.9375 23 C 18.390625 21.296875 20.0625 20 21.5 20 Z M 7 22 C 7.871094 22 8.355469 22.296875 8.789063 22.816406 C 9.226563 23.335938 9.550781 24.132813 9.742188 24.980469 C 10.128906 26.667969 10.003906 28.4375 10.003906 28.4375 C 9.992188 28.535156 9.996094 28.640625 10.015625 28.738281 C 10.011719 28.828125 10 28.914063 10 29 C 10 29.515625 10.089844 30.015625 10.226563 30.5 C 9.757813 30.066406 9.21875 29.636719 8.578125 29.183594 C 7.527344 28.445313 6.613281 27.738281 5.992188 26.945313 C 5.375 26.160156 5.011719 25.300781 5.007813 24.03125 C 5.007813 24.007813 5.046875 23.488281 5.320313 22.96875 C 5.601563 22.433594 5.9375 22 7 22 Z M 40.425781 22 L 42.378906 22 C 39.933594 23.8125 37.566406 26.269531 35.335938 28.253906 C 30.464844 32.589844 27.296875 34.796875 22.066406 34.984375 C 22.066406 34.980469 22.066406 34.980469 22.0625 34.984375 C 21.851563 34.992188 21.667969 35 21.5 35 C 21.546875 35 21.527344 35 21.441406 35 C 21.441406 34.996094 21.441406 34.996094 21.4375 35 C 21.417969 34.996094 21.398438 34.996094 21.375 34.996094 C 18.320313 34.96875 16.257813 34.363281 14.578125 33.183594 C 13.347656 32.316406 12 30.386719 12 29 C 12 27.28125 13.074219 25.832031 14.589844 25.265625 L 14.902344 25.175781 C 15.078125 25.125 15.246094 25.089844 15.410156 25.058594 C 15.605469 25.03125 15.796875 25 16 25 L 29.984375 25 L 29.964844 24.957031 C 34.296875 24.761719 38.023438 23.695313 40.425781 22 Z M 21.5 40 C 21.925781 40 22.339844 40.023438 22.742188 40.0625 C 23.90625 40.175781 24.933594 40.445313 25.675781 40.785156 C 25.824219 40.855469 25.871094 40.929688 25.996094 41 L 17.003906 41 C 17.128906 40.929688 17.175781 40.855469 17.324219 40.785156 C 18.066406 40.445313 19.09375 40.175781 20.257813 40.0625 C 20.660156 40.023438 21.074219 40 21.5 40 Z"/></g>'
529+
},
530530
{
531531
id: 'anagrams',
532532
name: 'Anagrams',

0 commit comments

Comments
 (0)