Oliviate / Blacked Booru Fav Link

// ==UserScript==
// @name         Blacked Booru Fav Link
// @namespace    https://blacked.booru.org/index.php?page=post&s=list&tags=all
// @version      1.0
// @license      GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @description  Add a fav link to every image in the list
// @author       Oliviate
// @match        https://blacked.booru.org/index.php?page=post&s=list*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=blacked.booru.org
// @grant        none
// ==/UserScript==

window.insertFavLink = function(id){
    let a = document.createElement('a');
    a.id = 'f'+id;
    a.href = '#';
    a.innerText = '♡';
    a.style = 'position: absolute;transform: translate(calc(-100% - 5px), 0);font-size: 20px;color: red;';
    a.setAttribute('onclick', `document.getElementById('notice').innerText=''; addFav('${id}'); this.remove(); return false;`);
    return a;
};

(function(win) {
    'use strict';

    try {
        console.log('script start');
        document.querySelectorAll('.thumb > a:first-of-type').forEach(a => a.parentNode.append(win.insertFavLink(a.id.substring(1))));
        console.log('script end');
    } catch(ex) {
        console.log('script error: ',ex);
    }


})(window);