Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard.
This is the base javascript:
(function (text) {
var node = document.createElement('textarea')
var selection = document.getSelection()| // create a <link> with specific URL | |
| var addLink = function(url){ | |
| var link = document.createElement('link'); | |
| link.src = url; | |
| link.rel = 'stylesheet'; | |
| link.type = 'text/css'; // no need for HTML5 | |
| document.getElementsByTagName('head')[0].appendChild(link); // for IE6 | |
| }; | |
| // create a style that can append CSS rules to <head> |
| // ==UserScript== | |
| // @name Copy Concatenator with Enable and Clear Buttons | |
| // @namespace your-namespace | |
| // @version 1 | |
| // @description Concatenates copied text and adds enable/disable and clear buttons to the page | |
| // @match *://*/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { |
| javascript: | |
| (function(){ | |
| var d=document,useMine=true,prevEl,info; | |
| function addHandler(orig,mine){ | |
| return function(e){ | |
| if(useMine){ | |
| mine(e); | |
| } | |
| else | |
| if(orig){ |
| javascript: (function() { | |
| var els, i, txt = ""; | |
| if (window.getSelection) { | |
| txt = window.getSelection(); | |
| } else if (document.getSelection) { | |
| txt = document.getSelection(); | |
| } else if (document.selection) { | |
| txt = document.selection.createRange().text; | |
| } else { | |
| txt = ""; |
| javascript: (function() { | |
| var d = document; | |
| var wrap = d.createElement('span'); | |
| wrap.style.position = 'relative'; | |
| wrap.className = 'wrap'; | |
| var cmt = d.createElement('textarea'); | |
| cmt.style.backgroundColor = 'yellow'; | |
| cmt.style.top = '1.5em'; | |
| cmt.style.position = 'absolute'; | |
| cmt.style.zIndex = '99'; |
| /* Handy bookmarklets to add excitement to ~✦☀selected text☀✦~ | |
| Any site you might actually want to use these on probably breaks them | |
| with their own weird javascript. | |
| */ | |
| // Light sparkles bookmarklet | |
| javascript:(function(){ | |
| function randomElement(array) { | |
| return array[Math.floor(Math.random() * array.length)]; | |
| } |
| (function() { | |
| var overlay = document.createElement('div'); | |
| Object.assign(overlay.style, { | |
| position: 'fixed', | |
| top: 0, | |
| left: 0, | |
| width: '100vw', | |
| height: '100vh', | |
| zIndex: 99999999, | |
| background: 'transparent', |
| javascript:(function(window, document) { | |
| var isScrolling, scrollTimeout; | |
| var defaultScrollSpeed = 50; | |
| var scrollSpeed = 50; | |
| var adjustIncrement = 2; | |
| var jumpIncrement = 50; | |
| function start() { | |
| window.addEventListener('keydown', keyPressed); | |
| window.addEventListener('keyup', keyReleased, false); |