Skip to content

Instantly share code, notes, and snippets.

@uu59
Created August 29, 2012 17:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uu59/3516026 to your computer and use it in GitHub Desktop.
Save uu59/3516026 to your computer and use it in GitHub Desktop.
kill ::selection { /* hard to see color */ }
// ==UserScript==
// @name avoid awesome selection
// @namespace http://uu59.org/
// @version 1.0.0
// @include *
// ==/UserScript==
// tested on http://www.vimninjas.com//2012/08/28/vim-for-rubyists-part-1/
function addStyle(css) {
var id = "avoid-awesome-selection";
var style = document.querySelector('#' + id);
if(!style) {
style = document.createElement('style');
style.id = id
style.type = "text/css";
document.querySelector('head, body').appendChild(style);
}
style.appendChild(document.createTextNode(css));
}
// ::selection colors cannot restore default?
// http://stackoverflow.com/questions/8676276/how-can-i-use-css3-selection-without-changing-the-default-color-and-background
var style = '{'+
'color: #010101 !important;'+
'background: rgba(200,200,255, 0.99) !important;'+ // for chrome: http://www.w3.org/TR/selectors/#selection
'text-shadow: none !important;'+
'box-shadow: none !important;'+
'-moz-box-shadow: none !important;'+
'}';
// should not use "," for multiple rules(they are ignored), should dependent each rules
addStyle('*::selection ' + style);
addStyle('*::-moz-selection ' + style);
{
"manifest_version": 2,
"name": "avoid awesome selection",
"version": "1.0.0",
"description": "get out ::selection { color: #000; background-color: #111; }",
"icons":
{
},
"content_scripts": [
{
"js": [
"avoid-awesome-selection.user.js"
],
"matches": [
"<all_urls>"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment