NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name DG ASIN Counter - Argus // @namespace kalpdev // @version 0.2.8 // @description ASIN Counter for Argus // @author @shjaisw // @include https://argus.aka.amazon.com/* // @updateURL https://openuserjs.org/meta/kalpdev.1/DG_ASIN_Counter_-_Argus.meta.js // @downloadURL https://openuserjs.org/install/kalpdev.1/DG_ASIN_Counter_-_Argus.user.js //@require https://cdn.jsdelivr.net/npm/sweetalert2@10 // @grant GM_addStyle // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @require https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.es6.min.js // @require https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js // @match http://pnq-412gv7q.ant.amazon.com:8087/* // @grant GM_xmlhttpRequest // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @grant GM_getValue // @grant GM_setValue // @grant GM_addStyle // @grant GM_setClipboard // @match http://*/* // @match https://argus.aka.amazon.com/* // @grant GM_getValue // @grant GM_setValue // @grant GM_addStyle // @grant GM_setClipboard // @require https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.1/xlsx.full.min.js // @license MIT // @require https://drive.corp.amazon.com/view/C-Ops-CN-PA/jquery/jquery-2.1.4.min.js // ==/UserScript== (function () { GM_addStyle('@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css");'); var targetElementSelectors = [ '#dtSubmitAndNextButton', '#dtSubmitAndExitButton', '#dtAcknowledgeAndNextButton', '#dtAcknowledgeAndExitButton', ]; var clickCount = GM_getValue('clickCount', 0); var displayElement; var resetAllButton; var asinLog = []; function createDisplayElement() { displayElement = document.createElement('div'); displayElement.id = 'clickCountDisplay'; displayElement.style.position = 'fixed'; displayElement.style.top = '1px'; displayElement.style.right = '173px'; displayElement.style.padding = '0 10px'; displayElement.style.width = '60px'; displayElement.style.textAlign = 'center'; displayElement.style.backgroundColor = '#fff'; displayElement.style.color = '#000'; displayElement.style.border = '3px solid #000000'; displayElement.style.borderRadius = '14px'; displayElement.style.zIndex = '9999'; displayElement.style.cursor = 'pointer'; displayElement.addEventListener('click', toggleEditMode); document.body.appendChild(displayElement); updateDisplay(); } function toggleEditMode() { displayElement.contentEditable = true; displayElement.style.backgroundColor = '#fff'; displayElement.style.outline = 'none'; displayElement.focus(); displayElement.addEventListener('keydown', handleKeyPress); } function handleKeyPress(event) { if (event.key === 'Enter') { event.preventDefault(); var inputText = displayElement.textContent; var inputValue = parseInt(inputText.trim()) || 0; clickCount = inputValue; GM_setValue('clickCount', clickCount); updateDisplay(); displayElement.contentEditable = false; displayElement.style.backgroundColor = '#fff'; displayElement.style.outline = 'none'; displayElement.removeEventListener('keydown', handleKeyPress); } } function copyAsinsToLog() { var productNameInputs = document.querySelectorAll('input.product-name-input'); productNameInputs.forEach(function (productNameInput) { var productName = productNameInput.value.trim(); if (productName && !asinLog.includes(productName)) { var timestamp = getCurrentDateTime(); asinLog.push([productName, timestamp]); } }); } function getCurrentDateTime() { var now = new Date(); var date = now.toISOString().slice(0, 10); var time = now.toTimeString().split(' ')[0]; return `${date} ${time}`; } function getUserId() { const badgePhoto = document.querySelector('.spoof-user-badge-pic'); const userIdMatch = badgePhoto.src.match(/uid=([^&]+)/); return userIdMatch ? userIdMatch[1] : 'unknown'; } function createCopyButton() { copyAsinsToLog(); } function createDownloadButton() { var downloadButton = document.createElement('button'); downloadButton.style.position = 'fixed'; downloadButton.style.top = '23px'; downloadButton.style.right = '202px'; downloadButton.style.width = '30px'; downloadButton.style.height = '30px'; downloadButton.style.borderRadius = '50%'; downloadButton.style.padding = '1px 1px'; downloadButton.style.backgroundColor = '#fff'; downloadButton.style.color = '#000'; downloadButton.style.zIndex = '9999'; downloadButton.style.marginLeft = '10px'; var downloadIcon = document.createElement('i'); downloadIcon.className = 'fas fa-download'; downloadButton.appendChild(downloadIcon); document.body.appendChild(downloadButton); downloadButton.addEventListener('click', function () { var wsData = [['ASIN', 'Time Copied', 'Date Copied', 'User ID'], ...asinLog.map(item => [item[0], item[1].split(' ')[1], item[1].split(' ')[0], item[2]])]; var ws = XLSX.utils.aoa_to_sheet(wsData); var wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, 'ASIN_Log'); var blob = new Blob([s2ab(XLSX.write(wb, { bookType: 'xlsx', type: 'binary' }))], { type: 'application/octet-stream', }); var date = new Date().toISOString().slice(0, 10); var userId = getUserId(); var fileName = userId + '_Productive_ASINs_' + date + '.xlsx'; if (navigator.msSaveBlob) { // IE10+ compatible navigator.msSaveBlob(blob, fileName); } else { var link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = fileName; link.click(); } }); } function s2ab(s) { var buf = new ArrayBuffer(s.length); var view = new Uint8Array(buf); for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF; return buf; } function createResetAllButton() { var resetAllButton = document.createElement('button'); resetAllButton.style.position = 'fixed'; resetAllButton.style.top = '23px'; resetAllButton.style.right = '173px'; resetAllButton.style.width = '30px'; resetAllButton.style.height = '30px'; resetAllButton.style.borderRadius = '50%'; resetAllButton.style.padding = '1px 1px'; resetAllButton.style.backgroundColor = '#fff'; resetAllButton.style.color = '#000'; resetAllButton.style.zIndex = '9999'; resetAllButton.style.marginLeft = '10px'; var resetAllIcon = document.createElement('i'); resetAllIcon.className = 'fa-solid fa-rotate-right fa-flip-horizontal'; resetAllButton.appendChild(resetAllIcon); document.body.appendChild(resetAllButton); resetAllButton.addEventListener('click', function () { var confirmReset = confirm('Do you want to delete all entry?'); if (confirmReset) { clickCount = 0; asinLog = []; GM_setValue('clickCount', clickCount); updateDisplay(); } }); } function updateDisplay() { displayElement.textContent = '' + clickCount; } function showCustomDialog(message, duration) { const dialogElement = document.createElement('div'); dialogElement.textContent = message; dialogElement.style.position = 'fixed'; dialogElement.style.top = '10px'; dialogElement.style.left = '50%'; dialogElement.style.transform = 'translate(-50%, -50%)'; dialogElement.style.backgroundColor = 'rgba(255, 255, 255, 0.5)'; dialogElement.style.color = '#000'; dialogElement.style.padding = '10px'; dialogElement.style.borderRadius = '10px'; dialogElement.style.zIndex = '9999'; document.body.appendChild(dialogElement); setTimeout(function () { document.body.removeChild(dialogElement); }, duration); } createDisplayElement(); createCopyButton(); createDownloadButton(); createResetAllButton(); document.addEventListener('click', function (event) { if (event.target.id === 'dtSubmitAndNextButton' || event.target.id === 'dtSubmitAndExitButton') { const productNameInput = document.querySelector('input.product-name-input'); if (productNameInput) { const productName = productNameInput.value.trim(); // Check if productName already exists in the log const isAsinDuplicate = asinLog.some(asin => asin[0] === productName); if (productName && !isAsinDuplicate) { // Add the ASIN with the current date, time, and user ID var timestamp = getCurrentDateTime(); var userId = getUserId(); asinLog.push([productName, timestamp, userId]); clickCount++; GM_setValue('clickCount', clickCount); updateDisplay(); const message = `ASIN Added connect @shjaisw for more details: ${productName}`; showCustomDialog(message, 3000); // Show message for 2 seconds GM_setClipboard(productName); } } } }); GM_addStyle(` #clickCountDisplay { #clickCountDisplay { font-size: 12px; font-family: Arial; font-weight: bold; } `); })();