Skip to content

Instantly share code, notes, and snippets.

@Yukaii
Last active August 24, 2024 07:55
Show Gist options
  • Save Yukaii/9d1893b134b5721b53622834385fa956 to your computer and use it in GitHub Desktop.
Save Yukaii/9d1893b134b5721b53622834385fa956 to your computer and use it in GitHub Desktop.
Taaze ISBN input helper.

Taaze Helper Script

The script automatically focuses on the ISBN input field after submission. Very useful when working with barcode scanner app.

Installation

  • Tampermoneky
  • Click this link
// ==UserScript==
// @name Focus and Autofocus ISBN Input
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @description Automatically focuses and selects text in the ISBN input after saving a product.
// @author Yukai
// @match https://www.taaze.tw/addProdUsed.html?typeFlg=IB
// @icon https://www.google.com/s2/favicons?sz=64&domain=taaze.tw
// @downloadURL https://gist.githubusercontent.com/Yukaii/9d1893b134b5721b53622834385fa956/raw/taaze-isbn-helper.user.js
// @updateURL https://gist.githubusercontent.com/Yukaii/9d1893b134b5721b53622834385fa956/raw/taaze-isbn-helper.user.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to handle the button click
function handleButtonClick() {
const isbnInput = document.getElementById('isbnInput');
if (isbnInput) {
// Add autofocus attribute
isbnInput.setAttribute('autofocus', 'autofocus');
// Focus and select the text in the input
isbnInput.focus();
isbnInput.select();
}
}
// Add event listener to the button
const addButton = document.getElementById('addBtn');
if (addButton) {
addButton.addEventListener('click', handleButtonClick);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment