Created
July 16, 2021 15:31
-
-
Save stevecheckoway/ac8a2ed2840e3804b69a69b318efd805 to your computer and use it in GitHub Desktop.
Tampermonkey script to copy the selection in f-puzzles.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Copy selection | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Copy the value of selected cells | |
// @author Stephen Checkoway | |
// @match https://*.f-puzzles.com/* | |
// @match https://f-puzzles.com/* | |
// @icon https://www.google.com/s2/favicons?domain=f-puzzles.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const doShim = function() { | |
const prevOnKeyDown = document.onkeydown; | |
document.onkeydown = function(event) { | |
if (event.key != 'c' || !(event.ctrlKey || event.metaKey)) { | |
prevOnKeyDown(event); | |
return; | |
} | |
let output = ""; | |
for (let idx = 0; idx < window.selection.length; ++idx) { | |
output += window.selection[idx].value; | |
} | |
navigator.clipboard.writeText(output); | |
event.preventDefault(); | |
} | |
} | |
if (window.grid) { | |
doShim(); | |
} else { | |
document.addEventListener('DOMContentLoaded', (event) => { | |
doShim(); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment