blob: 456fb1b9430616fc9766208079a319c2189421cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// ==UserScript==
// @name Instagram to Bibliogram
// @author Jesús E.
// @namespace BibliogramRedirect
// @description Scan page for Instagram and urls replace with Bibliogram
// @homepageURL https://git.sr.ht/~heckyel/book/blob/master/scripts-greasemonkey
// @include *
// @exclude /^http(s|)://(www[.]|)bibliogram[.]art/.*$/
// @exclude /^http(s|)://(www[.]|)bibliogram[.]snopyta[.]org/.*$/
// @exclude /^http(s|)://(www[.]|)bibliogram[.]pussthecat[.]org/.*$/
// @version 0.1.6
// @grant none
// @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
// ==/UserScript==
/* jshint esversion: 6 */
// Set you favorite Bibliogram instance! (https://github.com/cloudrac3r/bibliogram/wiki/Instances#instance-list)
let instance = 'bibliogram.snopyta.org';
// Console Style - Debug
const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
const name = GM_info.script.name;
const version = GM_info.script.version;
const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
// Do the actual rewrite
function rewriteLinks() {
for (let i = 0; i < document.links.length; i++) {
let elem = document.links[i];
if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)instagram[.]com\/(#!\/)?(.*$)/i)) {
elem.href='https://' + instance + '/u/' + RegExp.$4;
}
}
log('successfully initialized');
}
window.addEventListener('load', () => {
rewriteLinks();
});
|