Skip to content

Instantly share code, notes, and snippets.

@malipetek
Created January 9, 2019 19:55
Show Gist options
  • Save malipetek/b07089df8446535fe97cc4c94c106fd4 to your computer and use it in GitHub Desktop.
Save malipetek/b07089df8446535fe97cc4c94c106fd4 to your computer and use it in GitHub Desktop.
Beeline replicator. *this may be working only in chrome.
var d = document.createElement('div')
d.innerHTML += `
<style>
.grdnt {
-webkit-text-fill-color: transparent;
background: -webkit-gradient(linear, left top, right bottom, from(#26BDA6), to(#FF5722));
-webkit-background-clip: text;
background-size: 100% 1.5em;
}
</style>`
document.head.appendChild(d);
function dig(el){
el.childNodes.forEach(n => {
if(n.nodeType == 3){
var sc = document.createElement('span')
n.textContent.split(/(?=[\.\,\:\;])/gi).forEach(sentence => {
s = document.createElement('span')
s.textContent = sentence
s.classList.add('grdnt')
sc.appendChild(s)
})
n.replaceWith(sc)
}else if(n.classList && !n.classList.contains('grdnt')){
dig(n)
}
})
}
dig(document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment