Create a bookmark with this URL:
javascript:void function(){const e="https://hexworld.org/board/#",r=window.location.href,n=r.match(/\/table\?table=(\d+)/),o=r.match(/\/gamereview\?table=(\d+)/),t=r.match(/\/replay\/.*?\/\?table=\d+/);function a(e){return e.match(/\/(\d+\/hex)\?table=(\d+)/)}const i=a(r);let s="";function l(e){let r,n;return e.reduce((e,r)=>[...e,...r.data],[]).map(({type:e,args:o,log:t})=>{if("message"===e&&o.size){o.red&&!r?r=String(o.red):console.warn('No "args.red"');const e=o.size.match(/(\d+)x\d+/);if(e)return e[1]+"c1,"}if("playToken"===e){r||(r=o.player_id);const e=n==o.player_id?":p"+o.coord:o.coord;return n=o.player_id,e}return"swapPieces"===e?(n=o.player_id,":s"):"pass"===e?(n=o.player_id,":p"):"resign"===e||"playerConcedeGame"===e?o.player_id==r?":rb":":rw":void 0}).join("")}function c(e){return fetch(window.location.origin+e,{cache:"no-cache",headers:{"X-Request-Token":s}})}function d(e,r,n){return c(e?`/archive/archive/logs.html?table=${r}`:`/${n}/hex/notificationHistory.html?table=${r}&from=1&privateinc=1&history=1`).then(e=>e.json()).then(r=>{if("0"===String(r.status)&&r.error)throw new Error(`Error while fetching the move history: ${r.error}`);const n=e?r.data.logs:r.data.data;return console.info("Events:",n),l(n)})}function h(r,n,o){const t=window.open("about:blank");t.document.write("<p>Loading...</p>"),d(r,n,o).catch(e=>{if(e instanceof Error&&e.message.includes("Cannot find gamenotifs log file of an archived table"))return function(e){return console.info(`Requesting table archives for #${e}`),c(`/gamereview/gamereview/requestTableArchive.html?table=${e}`).then(e=>e.json()).then(e=>{if(1!==e.status){if(e.error)throw new Error(`Error while requesting the table archive: ${e.error}`);console.warn("result.status !== 1",e)}})}(n).then(()=>d(r,n,o));throw e}).then(r=>{console.info(`HexWorld hash: ${r}`),t.location.href=e+r}).catch(e=>{if(t.close(),console.error(e),String(e).includes("is not valid JSON"))return window.alert("Error. Try to reload the page.");window.alert(String(e))})}if("undefined"==typeof bgaConfig?console.error('No "bgaConfig" variable found, cannot get the request token'):s=bgaConfig.requestToken,i){const e=i[1];h(!1,i[2],e)}else{if(n){const e=n[1],r=document.querySelector("#access_game_panel");if(r&&"none"!==r.style.display){const e=document.querySelector("#view_end_btn");if(!e||!e.href)return window.alert("Error: Cannot find #view_end_btn");const r=a(e.href);return r?void h(!1,r[2],r[1]):window.alert(`Cannot parse the url: ${e.href}`)}return r||console.warn("Cannot detect if the game is finished."),void h(!0,e)}if(o)h(!0,o[1]);else if(t){if("undefined"==typeof g_gamelogs||!g_gamelogs)return window.alert('Error: no "g_gamelogs" variable.');const r=l(g_gamelogs);window.open(e+r)}else window.alert("No table found. Use this bookmark while viewing a Hex game on Board Game Arena.")}}();
Click it while viewing a Hex table.
It can be executed on /hex
, /table
, /gamereview
, or /archive/replay
pages.
- 2023-04-29: Fixed the "cannot read property 'data' of undefined" error on finished tables caused by changes on BGA
- 2022-06-04: Fixed errors on finished / in progress tables caused by x-request-token changes on BGA