diff --git a/better-xcloud.user.js b/better-xcloud.user.js
index e58f689..c928491 100644
--- a/better-xcloud.user.js
+++ b/better-xcloud.user.js
@@ -22,6 +22,10 @@ var $STREAM_VIDEO;
var $SCREENSHOT_CANVAS;
var GAME_TITLE_ID;
+// Credit: https://www.iconfinder.com/iconsets/user-interface-outline-27
+const ICON_VIDEO_SETTINGS = '';
+const ICON_STREAM_STATS = '';
+
class MouseCursorHider {
static #timeout;
@@ -1784,8 +1788,6 @@ function injectVideoSettingsButton() {
return;
}
- // Credit: https://www.iconfinder.com/iconsets/user-interface-outline-27
- const ICON_VIDEO_SETTINGS = '';
// Create Video Settings button
const $btnVideoSettings = cloneStreamMenuButton($orgButton, 'Video settings', ICON_VIDEO_SETTINGS);
$btnVideoSettings.addEventListener('click', e => {
@@ -1811,7 +1813,6 @@ function injectVideoSettingsButton() {
$quickBar.style.display = 'none';
});
- const ICON_STREAM_STATS = '';
// Create Stream Stats button
const $btnStreamStats = cloneStreamMenuButton($orgButton, 'Stream stats', ICON_STREAM_STATS);
$btnStreamStats.addEventListener('click', e => {
@@ -1827,6 +1828,34 @@ function injectVideoSettingsButton() {
// Insert after Video Settings button
$orgButton.parentElement.insertBefore($btnStreamStats, $btnVideoSettings);
+ // Get "Quit game" button
+ const $btnQuit = $orgButton.parentElement.querySelector('button:last-of-type');
+
+ let isHolding = false;
+ let holdTimeout;
+ const onMouseDown = e => {
+ isHolding = false;
+ holdTimeout = setTimeout(() => {
+ isHolding = true;
+ }, 750);
+ };
+ const onMouseUp = e => {
+ holdTimeout && clearTimeout(holdTimeout);
+
+ if (isHolding) {
+ e.preventDefault();
+ e.stopPropagation();
+ confirm('Do you want to refresh the stream?') && window.location.reload();
+ }
+ isHolding = false;
+ };
+
+ $btnQuit.addEventListener('mousedown', onMouseDown);
+ $btnQuit.addEventListener('click', onMouseUp);
+
+ $btnQuit.addEventListener('touchstart', onMouseDown);
+ $btnQuit.addEventListener('touchend', onMouseUp);
+
// Render stream badges
const $menu = document.querySelector('div[class*=StreamMenu-module__menuContainer] > div[class*=Menu-module]');
$menu.appendChild(await StreamBadges.render());