Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ChangeDrawColorAndOtherThings
- // @namespace xd
- // @version 1.0
- // @description Change draw color on gametactic.org
- // @author Renkee
- // @match https://en.wottactic.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- const drawAndLineEndKeys = [
- "1", // regular
- "2", // arrow
- "3" // T
- ];
- const toolChangeKeybinds = {
- "q": "draw_context",
- "w": "line_context",
- "e": "eraser_context",
- "r": "note_context"
- };
- const keyColorPairs = {
- "a": 0xff0000, // a -> red
- "s": 0x0000ff, // s -> blue
- "d": 0xffff00 // d -> yellow
- };
- function changeDrawLineEnds(key) {
- for(let i = 0;i<3;i++) {
- if (i == (key - 1)) {
- $("#draw_end_type").children()[i].classList.add("active");
- $("#line_end_type").children()[i].classList.add("active");
- } else {
- $("#draw_end_type").children()[i].classList.remove("active");
- $("#line_end_type").children()[i].classList.remove("active");
- }
- }
- }
- // Event handlers
- $(window).on('load', (e) => { changeDrawLineEnds(1); }); // Set default draw/line end to regular
- $(window).keypress((event) => {
- // if not in text field
- if (!$(event.target).is('input, textarea')) {
- const key = event.key;
- if (keyColorPairs.hasOwnProperty(key)) {
- window.draw_color = keyColorPairs[key];
- window.line_color = keyColorPairs[key];
- } else if (toolChangeKeybinds.hasOwnProperty(key)) {
- window.active_context = toolChangeKeybinds[key];
- window.active_menu = toolChangeKeybinds[key];
- if (toolChangeKeybinds[key] == "eraser_context" || toolChangeKeybinds[key] == "note_context") window.enable_dragging(); else window.disable_dragging();
- } else if (key == "c") {
- window.clear();
- } else if (drawAndLineEndKeys.includes(key)) {
- changeDrawLineEnds(key);
- }
- }
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement