For some reason, I can't get this to work. I noticed it says,
document.addEventListener('keydown', function(event) {
Does that mean I should press the down key plus whatever key I want to use? (Although that just moves the page down, so I'm not sure that's right, either.)
I changed the top key from q to a, so it reads:
if (event.key === 'a') {
but simply pressing the letter a doesn't make anything happen, so I'm not sure what to think.
@Travelle I went out and back in again, got to the first screen, pressed A and nothing happened.
Closed the tab, changed it back to Q, went back to campaign...nothing.
Maybe it's my browser?
@Travelle Opera GX. I haven't tried to replicate it on a different Chromium browser that is more common, like edge. (Or even Brave, where I've had plenty of luck with Tampermonkey.)
Let me try on a couple of different browsers...
-----
I have no idea. I tried Brave...no.
Edge? No.
Edge with all the extensions turned off? Yes.
Okay, back to OGX.
Turn all extensions off? Yes.
Reactivate one by one? The only one I didn't turn back on is Google Docs Offline, so that might be it? Weird.
@WitchyWriter - That is very weird, what an extension to cause issues hahaI don't even think I have that extension on Edge, so...still no idea. xD
no more semicolons or needing to reload the page
this still needs a gui and to, like, close modals on all pages and i bet the same thing for gauntlet and other stuff would be cool
(btw do encounter options and exploring again need to be different keybinds? i didnt want to change the functionality but it feels weird since they're in the same place, they are only coded differently in lw because the latter refreshes the page)
(you can make first option and explore again the same key if you want!)
// ==UserScript==
// @name Lorwolf Campaign Accessibility
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Keyboard Bindings for Lorwolf
// @author T. & Bone Copy
// @grant none
// @match https://www.lorwolf.com/*
// @license MIT
// ==/UserScript==
(function() {
'use strict'
// You can change the keybinds to whatever you want. If you want to use arrow keys, use Arrow then the direction, ie. (event.key === 'ArrowUp')
const FIRST_OPTION_KEY = 'q'
const SECOND_OPTION_KEY = 'w'
const EXPLORE_AGAIN_KEY = 'e'
const FEED_ALL_KEY = 'f'
const CLOSE_MODAL_KEY = 'x'
const REFRESH_PAGE_KEY = 'r'
let areKeybindsActive = false
const keybindActions = {
[FIRST_OPTION_KEY]: () => clickButton(0),
[SECOND_OPTION_KEY]: () => clickButton(1),
[EXPLORE_AGAIN_KEY]: clickExploreAgain,
[FEED_ALL_KEY]: clickFeedAll,
[CLOSE_MODAL_KEY]: closeModal,
[REFRESH_PAGE_KEY]: () => window.location.reload()
}
const titleObserver = new MutationObserver(onTitleChange)
titleObserver.observe(document.querySelector('title'), { childList: true})
onTitleChange()
function onTitleChange(){
const isInCampaign = /https:\/\/www\.lorwolf\.com\/Campaign/.test(window.location.href)
if (isInCampaign && !areKeybindsActive) {
startUsingBindings()
}
if (!isInCampaign && areKeybindsActive) {
stopUsingBindings()
}
}
function startUsingBindings() {
areKeybindsActive = true
document.addEventListener('keydown', keydownListener)
}
function stopUsingBindings() {
areKeybindsActive = false
document.removeEventListener('keydown', keydownListener)
}
function keydownListener(event) {
if (keybindActions[event.key]) {
keybindActions[event.key]()
}
}
// Function to simulate a click on the explore buttons 0/1
function clickButton(optionId) {
const button = document.querySelector(`.exploreOption[data-option-id="${optionId}"]`)
if (button) {
button.click()
}
}
// Function to simulate a click on the "Explore Again" link
function clickExploreAgain() {
const exploreAgainLink = document.querySelector('.exploreAgainOption')
if (exploreAgainLink) {
exploreAgainLink.click()
}
}
// Function to simulate a click on the "Feed All" button
function clickFeedAll() {
const feedAllButton = document.querySelector('.partyFeedAllButton')
if (feedAllButton) {
feedAllButton.click()
}
}
// Function to close the modal and remove the backdrop
function closeModal() {
const closeButton = document.querySelector('.modal-header .close')
const modalBackdrop = document.querySelector('.modal-backdrop')
const wolfToyModal = document.getElementById('wolfToyRewardsModalContent')
if (closeButton) {
closeButton.click()
}
if (modalBackdrop) {
modalBackdrop.remove()
}
if (wolfToyModal) {
wolfToyModal.remove()
}
}
})()
what came first, bone copy or bone paste?
Recent |
Subscribed |
My posts |