Skip to content

Instantly share code, notes, and snippets.

@mathieucaroff
Last active September 11, 2022 06:53
Show Gist options
  • Select an option

  • Save mathieucaroff/bbfc55991afdf220b88a886e155c99b9 to your computer and use it in GitHub Desktop.

Select an option

Save mathieucaroff/bbfc55991afdf220b88a886e155c99b9 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Align Youtube Ponies@Dawn
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Make the video always occupy the same column, so as to make them easier to find
// @author Mathieu CAROFF
// @match https://www.youtube.com/channel/UCSJW3EMxeuQXZ00h4bihXvA/videos
// @grant none
// ==/UserScript==
(function() {
console.log("PADALIGNER start ok")
let leftmostUrlTitlePair = [ // these urls must be in the order of apparition of their videos in the page
["https://www.youtube.com/watch?v=p2-fWCgtkqk", "Protocat & Natus - Worthy"],
["https://www.youtube.com/watch?v=lf-3xMsGA3Q", "Tw3Lv3 - deepest depths"],
["https://www.youtube.com/watch?v=rKcdzhpMRM8", "funky venture"],
["https://www.youtube.com/watch?v=JVXtm9G0gSQ", "delusion"],
["https://www.youtube.com/watch?v=Xu4RaD0WE2A", "song for seapony lyra"],
["https://www.youtube.com/watch?v=pCKtRLBfU5s", "never left you"],
["https://www.youtube.com/watch?v=Eor3StDzBsQ", "sun of the night"],
["https://www.youtube.com/watch?v=nhbcU7E_XOU", "ice angel"],
["https://www.youtube.com/watch?v=K1CnAnCOBho", "stay"],
["https://www.youtube.com/watch?v=xhvuOWb9mIY", "witch"],
["https://www.youtube.com/watch?v=0EOp7cHSCbY", "introversion"],
["https://www.youtube.com/watch?v=v2dVJ4d-SKA", "deadline"],
["https://www.youtube.com/watch?v=Vz_6mkeSQOg", "birdcall"],
["https://www.youtube.com/watch?v=hvGF2EyK1-c", "cyberpink"],
["https://www.youtube.com/watch?v=B8Eh6zkBKGQ", "FWLR - OMG"],
["https://www.youtube.com/watch?v=mk9LBvTx30E", "whats up with the sun"],
["https://www.youtube.com/watch?v=8D47_hKE2go", "go with me"],
["https://www.youtube.com/watch?v=3nZscI-JXMc", "space and time"],
["https://www.youtube.com/watch?v=hJGpQseQp-Q", "phoenix"],
["https://www.youtube.com/watch?v=i44tp3NeJog", "nocturne"],
["https://www.youtube.com/watch?v=7MAhky7jROQ", "take flight"],
["https://www.youtube.com/watch?v=r3UqlK4jhBs", "mufaya - old kid's piano"],
["https://www.youtube.com/watch?v=fZiMI_KOpzs", "collective memories"],
["https://www.youtube.com/watch?v=vJ8yejb1hWc", "reverse rain"],
["https://www.youtube.com/watch?v=jHTvwtqhATE", "fonky chonk"],
["https://www.youtube.com/watch?v=oyBsEOSSoc0", "LOROU - epoch"],
["https://www.youtube.com/watch?v=GyHc2_HEj6E", "ill fly hight"],
["https://www.youtube.com/watch?v=mw-NKRblre4", "magic water"],
["https://www.youtube.com/watch?v=hVonXg6nYe0", "dome"],
["https://www.youtube.com/watch?v=UdBmx-v0864", "bat pony"],
["https://www.youtube.com/watch?v=fB7NtRAstbo", "paper lady"],
["https://www.youtube.com/watch?v=Hv9KFj8v5HM", "seventh element"],
["https://www.youtube.com/watch?v=abRKMGzVaPU", "eve"],
["https://www.youtube.com/watch?v=0eopWE1e0Lw", "breaking of dawn"],
["https://www.youtube.com/watch?v=-zhnaG9Jxqg", "on your own"],
]
let indexOffset = 0
let k = 0
let processPage = () => {
for (; k < leftmostUrlTitlePair.length; k++) {
let [url, title] = leftmostUrlTitlePair[k]
// /\ this is efficiency!
let link = document.querySelector(`#contents [href="/${url.split("/").slice(-1)[0]}"]`)
if (!link) return
// \/
// though it will break if any of the videos listed in the leftmosturl index is removed
let element = link.parentElement.parentElement.parentElement
let children = [...element.parentElement.children]
let index = children.indexOf(element)
let mod = (index + indexOffset) % 6
console.log(`PADALIGNER title ${title}, index ${index}, mod ${mod}`)
if (index > 0 && mod > 0) {
indexOffset += 6 - mod
let marginSize = `calc( 50% - ${mod * 107}px )`
children[index - mod].style.marginLeft = marginSize
children[index - 1].style.marginRight = marginSize
}
}
}
document.body.addEventListener("click", processPage, true)
processPage()
console.log("PADALIGNER end ok")
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment