From 2b1524e45ee04830f6989aa0d80fbbfe31f91606 Mon Sep 17 00:00:00 2001 From: PurpleMagick Date: Thu, 7 Jul 2022 10:29:55 +0300 Subject: [PATCH] Fix for userscript not working after UI update An UI update changed the top bar and the DOM structure. In particular, it affected the current user profile. The userscript could not find it to check the details of the logged in user. Updated the selector to match the new structure. --- One-Click-VTC/dist/StackOneClickVTC.user.js | 7 +++---- One-Click-VTC/src/canCreateInterface.ts | 2 +- One-Click-VTC/src/userscript-metadata-block.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/One-Click-VTC/dist/StackOneClickVTC.user.js b/One-Click-VTC/dist/StackOneClickVTC.user.js index 30a88c8..455918c 100644 --- a/One-Click-VTC/dist/StackOneClickVTC.user.js +++ b/One-Click-VTC/dist/StackOneClickVTC.user.js @@ -3,7 +3,7 @@ // @description Allows voting to close with a single click // @author CertainPerformance // @namespace https://github.com/CertainPerformance/Stack-Exchange-Userscripts -// @version 1.2.3 +// @version 1.2.4 // @include /^https://(?:[^/]+\.)?(?:(?:stackoverflow|serverfault|superuser|stackexchange|askubuntu|stackapps)\.com|mathoverflow\.net)/questions/\d+/ // @grant none // ==/UserScript== @@ -37,7 +37,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.canCreateInterface = void 0; const settings_1 = __webpack_require__(/*! ./settings */ "./src/settings.ts"); const canCreateInterface = () => { - const myProfile = document.querySelector('.my-profile'); + const myProfile = document.querySelector('.s-topbar--content .s-user-card'); if (!myProfile) { // Not logged in, or site is down, don't do anything return; @@ -777,8 +777,7 @@ const showToastError = (message) => { helpers.showToast(message, { transient: false, type: 'danger' }); }; exports.showToastError = showToastError; -const showToastInfo = (message) => { - const transientTimeout = helpers.suggestedTransientTimeout(message, true); +const showToastInfo = (message, transientTimeout = helpers.suggestedTransientTimeout(message, true)) => { helpers.showToast(message, { transientTimeout, transient: true, type: 'info' }); }; exports.showToastInfo = showToastInfo; diff --git a/One-Click-VTC/src/canCreateInterface.ts b/One-Click-VTC/src/canCreateInterface.ts index fcc0630..6e4d5ae 100644 --- a/One-Click-VTC/src/canCreateInterface.ts +++ b/One-Click-VTC/src/canCreateInterface.ts @@ -1,7 +1,7 @@ import { getSettings } from './settings'; export const canCreateInterface = () => { - const myProfile = document.querySelector('.my-profile'); + const myProfile = document.querySelector('.s-topbar--content .s-user-card'); if (!myProfile) { // Not logged in, or site is down, don't do anything return; diff --git a/One-Click-VTC/src/userscript-metadata-block.js b/One-Click-VTC/src/userscript-metadata-block.js index 1f78c7f..956bc8a 100644 --- a/One-Click-VTC/src/userscript-metadata-block.js +++ b/One-Click-VTC/src/userscript-metadata-block.js @@ -3,7 +3,7 @@ // @description Allows voting to close with a single click // @author CertainPerformance // @namespace https://github.com/CertainPerformance/Stack-Exchange-Userscripts -// @version 1.2.3 +// @version 1.2.4 // @include /^https://(?:[^/]+\.)?(?:(?:stackoverflow|serverfault|superuser|stackexchange|askubuntu|stackapps)\.com|mathoverflow\.net)/questions/\d+/ // @grant none // ==/UserScript==