Skip to content

Instantly share code, notes, and snippets.

@richard512
Created May 30, 2018 19:13
Show Gist options
  • Save richard512/985824e5ebfdfedad618b4ba76ce03e5 to your computer and use it in GitHub Desktop.
Save richard512/985824e5ebfdfedad618b4ba76ce03e5 to your computer and use it in GitHub Desktop.
Replace Reddit Stylesheet URLs with Reddit URL Variables -- Example: url(http://...) becomes url(%%01%%)
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2018 by anonymous (http://jsbin.com/nexafujuxu/1/edit)
Released under the MIT license: http://jsbin.mit-license.org
-->
<meta name="robots" content="noindex">
<textarea id="code">*{
font-family:"Trebuchet MS1",sans-serif!important
}
.nav-buttons{
padding:8px
}
.side{
padding-right:9px;
width:300px;
margin:0px;
margin-top:36px;
border:none;
padding-top:456px;
background:transparent
}
.side:before{
background:url("//b.thumbs.redditmedia.com/2HrqH51LuM7RkIxK7GMYcV6l8rMdhcJ50AjXhdqmUJc.png") top 0px left no-repeat;
height:400px;
z-index:0;
content:"";
width:300px;
position:absolute;
display:block;
top:292px
}
@keyframes play{
100%{
background-position:0px -4800px
}
}
.link .thumbnail{
height:58px;
width:59px;
margin:5px 5px 0px 0px!important;
border-radius:2px
}
.thumbnail.self{
background-image:url("//b.thumbs.redditmedia.com/hE5oxptJ1f5--UHYp4vGMB1PYA6FjWUB-qK7X8LiV8U.png")!important;
background-position:0px 0px;
margin-top:10px!important
}</textarea>
<script id="jsbin-javascript">
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
document.body.onclick = function() {
matches = code.value.match(/url\(\"\/\/.*\"\)/g)
for (i in matches){
newname = "url(%%" + pad(parseInt(i)+1, 2) + "%%)"
code.value = code.value.replace(matches[i], newname)
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment