Last active
November 29, 2017 18:50
-
-
Save a-nakanosora/8ab9ede8db32a7c8d0d14a727974600a to your computer and use it in GitHub Desktop.
UserScript # twitter - indent retweets & likes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name twitter - indent retweets & likes | |
// @namespace Violentmonkey Scripts | |
// @match *://mobile.twitter.com/* | |
// ==/UserScript== | |
(function(){ | |
/// for mobile.twitter.com | |
const svg_like_retweet = 'svg._1v21e2jc' | |
function getArticle(e){ | |
while(e){ | |
const a = e.getAttribute('role') | |
if(a && a==='article') | |
return e | |
e = e.parentNode | |
} | |
return null | |
} | |
function getVerticalPadding(a){ | |
const t = window.getComputedStyle(a,null).getPropertyValue("padding-top") | |
const b = window.getComputedStyle(a,null).getPropertyValue("padding-bottom") | |
return parseInt(t)+parseInt(b) | |
} | |
setInterval(_=>{ | |
Array.from(document.querySelectorAll(`${svg_like_retweet}:not([__proced__retweet_indent])`)).forEach(svg=>{ | |
const a = getArticle(svg) | |
if(!a) | |
return | |
const r = a.getClientRects()[0] | |
console.log('Obsidian', r) | |
Object.assign(a.style, { | |
'margin': '0px 0 0px 100px', | |
'border-left': '1px dotted #ccd6dd', | |
/// prevent resizing the height | |
'height': `${r.height - getVerticalPadding(a)}px`, | |
}) | |
svg.setAttribute('__proced__retweet_indent', true) | |
}) | |
}, 2000) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment