aboutsummaryrefslogtreecommitdiffstats
path: root/scripts-greasemonkey
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-02-23 20:15:08 -0500
committerJesús <heckyel@hyperbola.info>2020-02-23 20:15:08 -0500
commitbededa5414383549085f7ab820c104fefae73131 (patch)
treed39fd10492f24b163bfa509fde755671d8339e42 /scripts-greasemonkey
parent3af3aa73f9fb1dff832c61e60c1b44c1467ed0ab (diff)
downloadbook-bededa5414383549085f7ab820c104fefae73131.tar.lz
book-bededa5414383549085f7ab820c104fefae73131.tar.xz
book-bededa5414383549085f7ab820c104fefae73131.zip
Add BibliogramRedirect
Diffstat (limited to 'scripts-greasemonkey')
-rw-r--r--scripts-greasemonkey/instagram_to_bibliogram.user.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts-greasemonkey/instagram_to_bibliogram.user.js b/scripts-greasemonkey/instagram_to_bibliogram.user.js
new file mode 100644
index 0000000..114cd58
--- /dev/null
+++ b/scripts-greasemonkey/instagram_to_bibliogram.user.js
@@ -0,0 +1,40 @@
+// ==UserScript==
+// @name Instagram to Bibliogram
+// @author Jesús E.
+// @namespace BibliogramRedirect
+// @description Scan page for Instagram and urls replace with Bibliogram
+// @homepageURL https://libregit.org/heckyel/book/src/branch/master/scripts-greasemonkey
+// @include *
+// @exclude /^http(s|)://(www[.]|)bibliogram[.]art/.*$/
+// @exclude /^http(s|)://(www[.]|)bibliogram[.]snopyta[.]org/.*$/
+// @version 0.1.0
+// @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.art';
+
+// Console Style - Debug
+let consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
+
+// 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;
+ }
+ }
+ statuscheck()
+}
+
+function statuscheck(){
+ // Console Feedback
+ console.log("%cUSERSCRIPT | " + GM_info.script.name + " " + GM_info.script.version + " | successfully initialized", consoleCSS);
+}
+
+window.addEventListener('load', () => {
+ rewriteLinks();
+});