Skip to content

Commit 196edd2

Browse files
committed
Shorten the URLs generated by extensions to handle opening long games in Chrome
https://issues.chromium.org/issues/41322340
1 parent beba428 commit 196edd2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Running from the browser
5050
------------------------
5151

5252
After ChessHue is run once, the next time it can be started using the `chess://` protocol.
53-
You can pass your PGN in the URL, like `chess://e4 e5/`.
53+
You can pass your PGN in the URL, like `chess://e4_e5/`.
5454

5555
To analyse your games in ChessHue right after they end:
5656

@@ -66,10 +66,10 @@ To analyse your games in ChessHue right after they end:
6666
if (e.key === 'l' && document.querySelector('.game-review-buttons-component')) {
6767
const nodes = document.querySelectorAll('.main-line-ply');
6868
if (nodes.length > 0) {
69-
const moves = [...nodes].map(e => e.textContent);
69+
const moves = [...nodes].map(e => e.textContent.trim());
7070
const clock = document.querySelector('.clock-bottom');
7171
const color = clock.classList.contains('clock-black') ? 'b' : 'w';
72-
const url = `chess://${moves.join(' ')}/${color}`;
72+
const url = `chess://${moves.join('_')}/${color}`;
7373
window.open(url.replace('#', '%23'), '_blank');
7474
}
7575
}
@@ -83,10 +83,10 @@ To analyse your games in ChessHue right after they end:
8383
if (e.key === 'l' && document.querySelector('.rematch')) {
8484
const nodes = document.querySelectorAll('l4x kwdb');
8585
if (nodes.length > 0) {
86-
const moves = [...nodes].map(e => e.textContent);
86+
const moves = [...nodes].map(e => e.textContent.trim());
8787
const clock = document.querySelector('.rclock-bottom');
8888
const color = clock.classList.contains('rclock-black') ? 'b' : 'w';
89-
const url = `chess://${moves.join(' ')}/${color}`;
89+
const url = `chess://${moves.join('_')}/${color}`;
9090
window.open(url.replace('#', '%23').replace(/½\?/g, ''), '_blank');
9191
}
9292
}

src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
const url = await electron.getProtocolUrl();
9292
if (url) {
9393
const [pgn_or_fen, color] = url.split('/');
94-
this.pgn_or_fen = pgn_or_fen;
94+
this.pgn_or_fen = pgn_or_fen.replace(/_/g, ' ');
9595
if (color[0] === 'b') {
9696
this.board_flipped = true;
9797
}

0 commit comments

Comments
 (0)