Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Stealth ping
- // @namespace http://your.homepage/
- // @version 0.1
- // @description enter something useful
- // @author You
- // @match https://chat.stackexchange.com/rooms/240/the-nineteenth-byte
- // @grant none
- // ==/UserScript==
- function withJQuery(f) {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.textContent = '(' + f + ')(jQuery)';
- document.head.appendChild(script);
- }
- withJQuery(function($){
- function setSelectionRange(input, selectionStart, selectionEnd) {
- if (input.setSelectionRange) {
- input.focus();
- input.setSelectionRange(selectionStart, selectionEnd);
- }
- else if (input.createTextRange) {
- var range = input.createTextRange();
- range.collapse(true);
- range.moveEnd('character', selectionEnd);
- range.moveStart('character', selectionStart);
- range.select();
- }
- }
- function setCaretToPos (input, pos) {
- setSelectionRange(input, pos, pos);
- }
- var input = $('#input');
- input.keydown(function(e) {
- if (e.which == 81 && e.ctrlKey) {
- e.preventDefault();
- $(this).val($(this).val() + "[](http://@)");
- setCaretToPos(this, $(this).val().length - 1);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement