Last active
January 1, 2019 14:50
-
-
Save Klaster1/35a4f9455333dd2a90f7fc043fe3abbc to your computer and use it in GitHub Desktop.
Fast appeal
This file contains 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 Fast appeal | |
// @version 2 | |
// @grant none | |
// @match https://гибдд.рф/request_main | |
// @match https://xn--90adear.xn--p1ai/request_main | |
// @run-at document-end | |
// @icon https://гибдд.рф/favicon.ico | |
// ==/UserScript== | |
const removeAutocomplete = () => document.querySelectorAll('[autocomplete="off"]').forEach(el => el.setAttribute('autocomplete', 'on')) | |
const selectors = ['input', 'textarea', 'select'] | |
const getValues = (...selectors) => selectors.reduce((acc, s) => ({...acc, [s]: Array.from(document.querySelectorAll(s), (e) => e.value)}), {}) | |
const writeValues = (values) => Object.keys(values).forEach((key) => document.querySelectorAll(key).forEach((el, i) => el.value = values[key][i])) | |
// $(function(){function n(){return!1}document.ondragstart=n,document.onselectstart=n,document.oncontextmenu=n,document.oncopy=n,document.onpaste=n}); | |
const noNoCopy = () => { | |
['ondragstart', 'onselectstart', 'oncontextmenu', 'oncopy', 'onpaste'].forEach(key => { | |
Object.defineProperty(document, key, { | |
value: null, | |
writable: false, | |
// configurable: false | |
}) | |
}) | |
// Object.defineProperty(obj, "uuid", { configurable: false, writable: false }) | |
// document.ondragstart = document.onselectstart = document.oncontextmenu = document.oncopy = document.onpaste = null | |
} | |
const addUI = () => { | |
const panel = document.createElement('div') | |
panel.style.position = 'fixed' | |
panel.style.bottom = 0 | |
panel.style.left = 0 | |
const read = document.createElement('button') | |
read.type = 'button' | |
read.onclick = () => localStorage.lastAppeal = JSON.stringify(getValues(...selectors)) | |
read.innerText = 'Read' | |
const write = document.createElement('button') | |
write.type = 'button' | |
write.onclick = () => writeValues(JSON.parse(localStorage.lastAppeal)) | |
write.innerText = 'Write' | |
panel.append(read) | |
panel.append(write) | |
document.body.append(panel) | |
} | |
removeAutocomplete() | |
addUI() | |
noNoCopy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment