您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds quality of life features to Robinhood
当前为
// ==UserScript== // @name Robinhood QOL Trading // @namespace Trading // @match https://robinhood.com/legend/layout/* // @grant none // @version 1.0 // @license MIT // @author AdSam // @description Adds quality of life features to Robinhood // ==/UserScript== const TIMEOUT = 5; const BUY_KEY = "b"; const SELL_KEY = "s"; const SET_SHARES_KEY = "z"; function WaitForElement(selector, index, timeout = 0) { let iter = 0; return new Promise((resolve, reject) => { const interval = setInterval(() => { if (timeout != 0 && iter >= timeout * 1000) { reject(new Error("Timeout")); } const elements = document.querySelectorAll(selector); if (elements[index]) { clearInterval(interval); resolve(elements[index]); } iter++; }, 1); }); } async function buy(shares) { try { menuBtn = await WaitForElement( '[data-testid="legend_buy_button"]', 0, TIMEOUT ); menuBtn.click(); dropdown = await WaitForElement('[role="combobox"]', 0, TIMEOUT); dropdown.click(); market = await WaitForElement('[role="option"]', 1, TIMEOUT); market.click(); quantity = await WaitForElement('[name="quantity"]', 0, TIMEOUT); quantity.focus(); document.execCommand("selectAll"); document.execCommand("insertText", false, shares); while (quantity.value != shares) {} buyBtn = await WaitForElement('[type="submit"]', 0, TIMEOUT); buyBtn.click(); } catch { return 0; } return shares; } async function sell(shares) { try { menuBtn = await WaitForElement( '[data-testid="legend_sell_button"]', 0, TIMEOUT ); menuBtn.click(); dropdown = await WaitForElement('[role="combobox"]', 0, TIMEOUT); dropdown.click(); market = await WaitForElement('[role="option"]', 1, TIMEOUT); market.click(); quantity = await WaitForElement('[name="quantity"]', 0, TIMEOUT); quantity.focus(); document.execCommand("selectAll"); document.execCommand("insertText", false, shares.toString()); while (quantity.value != shares.toString()) {} sellBtn = await WaitForElement('[type="submit"]', 0, TIMEOUT); sellBtn.click(); } catch { return 0; } return shares; } let shares = 0; let totalShares = 0; let debounce = false; document.addEventListener("keydown", async (event) => { if (!debounce) { debounce = true; if (event.key == BUY_KEY) { totalShares += await buy(shares); } else if (event.key == SELL_KEY) { totalShares -= await sell(shares); } else if (event.key == SET_SHARES_KEY) { const res = parseFloat(prompt("Enter number of shares:")); if (res != null) { shares = res; } } debounce = false; } });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址