36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// ==UserScript==
|
|
// @name Redtolib
|
|
// @version 1.0
|
|
// @match https://*.reddit.com/*
|
|
// @match https://reddit.com/*
|
|
// @author Stabosa87
|
|
// @grant none
|
|
// @run-at document-end
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
const link = document.createElement('a');
|
|
link.innerText = 'VIEW ON REDLIB';
|
|
|
|
link.style.position = 'fixed';
|
|
link.style.top = '0';
|
|
link.style.left = '0';
|
|
link.style.zIndex = '6969696969';
|
|
link.style.display = 'none';
|
|
|
|
fetch("https://raw.githubusercontent.com/redlib-org/redlib-instances/main/instances.json")
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data && data.instances && data.instances.length > 0) {
|
|
const Redliburl = data.instances[0].url;
|
|
const path = window.location.pathname + window.location.search + window.location.hash;
|
|
link.href = Redliburl + path;
|
|
link.style.display = 'inline';
|
|
}
|
|
})
|
|
.catch(e => console.error(e));
|
|
|
|
document.body.appendChild(link);
|
|
})(); |