Greasy Fork is available in English.

Reddit Album to Cubari

Add button in posts with album to open cubari

// ==UserScript==
// @name        Reddit Album to Cubari
// @namespace   https://greasyfork.org/pt-BR/users/821661
// @description Add button in posts with album to open cubari
// @match       https://www.reddit.com/*
// @resource    cubariFavicon https://icon.horse/icon/cubari.moe
// @grant       GM_addStyle
// @grant       GM_getResourceURL
// @version     1.2
// @license     MIT
// ==/UserScript==
'use strict';

// Cubari favicon
const cubariFavicon = GM_getResourceURL('cubariFavicon');

// Check posts if have album elements
async function checkPosts() {
	while (true) {
		await new Promise(r => setTimeout(r, 1000));
		const postsWithAlbum = document.querySelectorAll('.Post:has(._3BxRNDoASi9FbGX01ewiLg):not([cubari])');
		postsWithAlbum.forEach(createButton);
	}
}
checkPosts();

// Create button for open cubari
function createButton(post) {
	post.setAttribute('cubari', '');
	const hrefPost = post.querySelector(':has(._2ED-O3JtIcOqp8iIL1G5cg)') ? post.querySelector('._2ED-O3JtIcOqp8iIL1G5cg a.SQnoC3ObvgnGjWt90zD9Z').href : post.querySelector('.SQnoC3ObvgnGjWt90zD9Z').href;
	const hrefID = hrefPost.match(/\/comments\/(.*?)\//)[1];

	const a = document.createElement('a');
	a.classList.add('cubari-button');
	a.innerHTML = `<img src="${cubariFavicon}"/>`;
	a.setAttribute('href', `https://cubari.moe/read/reddit/${hrefID}/`);
	a.setAttribute('target', '_blank');

	post.appendChild(a);
}

// Add style to button
GM_addStyle(`
    .cubari-button {
        position: absolute;
        bottom: 5px;
        right: 5px;
        z-index: 9;
        filter: drop-shadow(0 0 3px #000);
    }
    .cubari-button > img {
        height: 30px;
    }
`);