Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name httpS, handy kukarek by hotkey
- // @namespace FM veshtschaniye
- // @version 0.0.5.3
- // @match http://anon.fm
- // @match http://alcxemuct.accountant
- // @match https://anon.fm
- // @match https://anon.fm/info.html
- // @match https://anon.fm/menu.html
- // @match https://anon.fm/mobile/a.html
- // @match https://alcxemuct.accountant
- // @match https://alcxemuct.accountant/info.html
- // @match https://alcxemuct.accountant/menu.html
- // @match https://alcxemuct.accountant/mobile/a.html
- // @grant none
- // ==/UserScript==
- // 1. Redirects from HTTP to HTTPS version
- // 2. Adds hotkey 'K' to open Kukarekalka window
- // 3. Pastes selected text to Kukarekalka window
- // HTTPS redirection
- if (location.protocol[4] !== 's') window.location = location.href.replace('p','ps');
- // Kukarekalka opener
- let kukarekWindow = null;
- addEventListener('keyup', e => {
- if (e.ctrlKey || e.shiftKey || e.altKey) return;
- const node = document.activeElement.nodeName;
- if (node === 'TEXTAREA' || node === 'INPUT') return;
- if (e.code === 'KeyK') {
- if (kukarekWindow && !kukarekWindow.closed) kukarekWindow.focus();
- else kukarekWindow = window.open(`https://${location.host}/feedback/`,'win1feedback','top=-1,left=250,width=560,height=235,toolbar=no');
- if (getSelection().toString() !== '') appendText(getSelection().toString().trim().replace(/\n+/g, '\n').replace(/(^|\n)/g, '$1> ')+'\n');
- }
- });
- // Selected text paster
- function appendText(text) {
- let t = kukarekWindow.document.getElementById('te');
- if (!t) return setTimeout(()=>appendText(text), 100);
- if (t.value.endsWith(text)) return; // Skip if text already pasted
- if (t.value !== '' && !t.value.endsWith('\n')) t.value += '\n'; // Add new line to existing text
- t.value += text; // Append selection
- t.selectionStart = -1; // Set cursor to last position
- };
Add Comment
Please, Sign In to add comment