Skip to content

Instantly share code, notes, and snippets.

@ScottKaye
Last active September 10, 2015 02:30
Show Gist options
  • Save ScottKaye/d174dff3dd241f4c1a74 to your computer and use it in GitHub Desktop.
Save ScottKaye/d174dff3dd241f4c1a74 to your computer and use it in GitHub Desktop.
Disables control-f results, text selection, and all other interaction for any bit of text.
(function ($) {
$.fn.shadow = function () {
this.each(function () {
var text = this.innerText;
this.createShadowRoot()
.innerHTML = "<style>:host::after{content:'" + text + "'}</style>";
});
return this;
};
$.extend({
shadow: function (selector) {
return $(selector).shadow();
}
});
})(jQuery);
//Usage
$.shadow(".shadow");
//or
$(".shadow").shadow();
(function () {
var shadows = document.getElementsByClassName("shadow");
Array.prototype.forEach.call(shadows, function (el) {
var text = el.innerText;
el.createShadowRoot()
.innerHTML = "<style>:host::after{content:'" + el.innerText + "'}</style>";
});
})();
<p>
This is some text that has a <span class="shadow">hidden</span> word that can't be found using control-F!
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment