您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds helpful keyboard shortcut keys to steamgifts.com
当前为
// ==UserScript== // @name steamgifts.com shortcut keys // @namespace Barefoot Monkey // @description Adds helpful keyboard shortcut keys to steamgifts.com // @include http://www.steamgifts.com/giveaway/* // @include http://www.steamgifts.com/support/* // @include http://www.steamgifts.com/discussion/* // @match http://www.steamgifts.com/support/* // @match http://www.steamgifts.com/giveaway/* // @match http://www.steamgifts.com/discussion/* // @version 2 // ==/UserScript== try { var OP_name var is_giveaway, is_forum, is_support // determine where on the site we are visiting var path_matches = location.pathname.match(/^\/([^\/]*)\/([^\/]*)\/.*/) if (path_matches) { switch (path_matches[1]) { case 'giveaway': is_giveaway = true; break // case 'support': is_support = true; break case 'discussion': is_forum = true; break } } // discover the name of the author of the thread/giveaway if (is_giveaway) { var name_element = document.querySelector('.featured__summary .featured__column a') if (name_element) { OP_name = name_element.textContent.trim() } } else if (is_forum) { var name_element = document.querySelector('.comment__username>a') if (name_element) { OP_name = name_element.textContent.trim() } } // catch keypress events document.addEventListener("keydown", function(event) { try { // ctrl shortcut keys to focus or submit the textbox if (event.ctrlKey && !event.repeat) { // ctrl+enter if (event.which == 13) { var active = document.activeElement if (active && active === document.querySelector('.comment--submit div.comment__description>form>textarea[name=description]')) { var button = document.querySelector('.comment--submit .comment__submit-button') if (button) { button.dispatchEvent( new MouseEvent('click', { 'view': window, 'bubbles': true, 'cancelable': true }) ) event.preventDefault() } } } // ctrl+space else if (event.which == 32) { // find the comment textarea var textbox = document.querySelector('.comment--submit div.comment__description>form>textarea[name=description]') // give focus to the comment textarea if (textbox) { textbox.focus() event.preventDefault() } } } if (event.altKey && !event.repeat) { // ignore case var which = event.which|32 // alt+e = enter the giveaway if (is_giveaway && which == 101) { var button if (event.shiftKey) { button = document.querySelector('.sidebar__entry-delete:not(.is-hidden)') } else { button = document.querySelector('.sidebar__entry-insert:not(.is-hidden)') } if (button) { button.dispatchEvent( new MouseEvent('click', { 'view': window, 'bubbles': true, 'cancelable': true }) ) } event.preventDefault() // handle comment-editing shortcuts } else { var active = document.activeElement if (active && active === document.querySelector('.comment--submit div.comment__description>form>textarea[name=description]')) { // alt+o = original poster's name if (which == 111) { // insert OP's name it into the comment if (OP_name) { // take note of the cursor position var cursor_pos = active.selectionStart // insert the name var text = active.value active.value = (text.substring(0, cursor_pos) + OP_name + text.substring(active.selectionEnd)) // move the cursor cursor_pos += OP_name.length active.setSelectionRange(cursor_pos, cursor_pos) // prevent the browser from handling this event event.preventDefault() } // alt+p or alt+r = parent poster's name } else if (which == 112 || which == 114) { // prevent ctrl+alt+p because of reported conflict with Puush if (event.ctrlKey && event.altKey && which == 112) return; // traverse up the DOM tree to find name of the parent post's author var PP_name = OP_name { var parent = active while (parent = parent.parentNode) { if (parent.classList && parent.classList.contains('comment') && !parent.classList.contains('comment--submit')) { var name_e = parent.querySelector('.comment__username>a') if (name_e) PP_name = name_e.textContent.trim() break } } } // insert PP's name it into the comment if (PP_name) { // take note of the cursor position var cursor_pos = active.selectionStart // insert the name var text = active.value active.value = (text.substring(0, cursor_pos) + PP_name + text.substring(active.selectionEnd)) // move the cursor cursor_pos += PP_name.length active.setSelectionRange(cursor_pos, cursor_pos) // prevent the browser from handling this event event.preventDefault() } } } } } } catch (exception) { console.log(exception) } }, true) } catch (exception) { console.log(exception) }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址