Skip to content

Instantly share code, notes, and snippets.

View fadeouter's full-sized avatar

fadeouter

  • middlewhere
View GitHub Profile
@Yaffle
Yaffle / test.js
Last active January 24, 2025 11:33
get/set caret position in contenteditable element
// Usage:
// var x = document.querySelector('[contenteditable]');
// var caretPosition = getSelectionDirection(x) !== 'forward' ? getSelectionStart(x) : getSelectionEnd(x);
// setSelectionRange(x, caretPosition + 1, caretPosition + 1);
// var value = getValue(x);
// it will not work with "<img /><img />" and, perhaps, in many other cases.
function isAfter(container, offset, node) {
var c = node;
@TheDrHax
TheDrHax / script.js
Last active November 22, 2019 07:27
Скрипт для GreaseMonkey, быстро прокликивающий все нужные кнопки на https://auth.wi-fi.ru/
// ==UserScript==
// @name MosMetroV2.js
// @description This script skips annoying quizes and full screen ads on https://auth.wi-fi.ru
// @author Dmitry Karikh <mosmetro@thedrhax.pw> (https://github.com/mosmetro-android)
// @version 2
// @grant none
// @include *://auth.wi-fi.ru/auth*
// ==/UserScript==
(function () {
@nalgeon
nalgeon / cities.md
Last active July 9, 2025 13:38
Города России с координатами
@islishude
islishude / caret.js
Last active November 26, 2023 00:16
[DEPRECATED]get/set caret position in contentEditable or textarea/input element(JavaScript)
/**
* @file get/set caret position and insert text
* @author islishude
* @license MIT
*/
export class Caret {
/**
* get/set caret position
* @param {HTMLColletion} target
*/
@carsondarling
carsondarling / notify-send.sh
Last active September 6, 2021 09:15
Replacement for notify-send to auto-remove notifications for Gnome Shell.
#!/bin/sh
# Save this script as /usr/local/bin/notify-send and make sure to chmod +x!
# NOTE: This has not been extensively tested, though it does work with
# XChat. Let me know if it works with others!
# Make all notify-send calls go away after they've popped up
/usr/bin/notify-send --hint int:transient:1 $@
@fnicollier
fnicollier / insertAtCaret.js
Created December 11, 2012 13:12
Insert text into a textarea at cursor position
//http://www.scottklarr.com/topic/425/how-to-insert-text-into-a-textarea-where-the-cursor-is/
function insertAtCaret(areaId,text) {
var txtarea = document.getElementById(areaId);
var scrollPos = txtarea.scrollTop;
var strPos = 0;
var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ?
"ff" : (document.selection ? "ie" : false ) );
if (br == "ie") {
txtarea.focus();
var range = document.selection.createRange();