Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User script suggestion (tested only on iOS) #89

Open
SoftwareRat opened this issue Feb 12, 2023 · 0 comments
Open

User script suggestion (tested only on iOS) #89

SoftwareRat opened this issue Feb 12, 2023 · 0 comments

Comments

@SoftwareRat
Copy link

For README:

This is a user script which redirects IMDB, Imgur, Instagram, Medium, Odysee, Quora, Reddit, TikTok, Twitter and YouTube to farside.link

I developed this so I can use it on iOS with the help of the https://apps.apple.com/app/userscripts/id1463298887 extension

// ==UserScript==
// @name Redirect to Farside Link
// @version 1.4
// @description Redirects matching URLs to Farside Link
// @author SoftwareRat
// @match *://*/*
// @grant none
// ==/UserScript==

(function() {
    'use strict';

    const regex = /^(?:https?:\/\/)(?:www\.)?((?:imdb|m\.imdb|imgur|instagram|medium|odysee|quora|reddit|tiktok|translate|twitter|youtube)\.(?:com|org|google\.(?:com|au|de|co)))/;
    const googleRegex = /^(?:https?:\/\/)(?:www\.)?google\.([a-zA-Z]+)\//;
    const url = window.location.href;
    const match = url.match(regex);
    const googleMatch = url.match(googleRegex);

    if (match) {
        window.stop();
        const redirectUrl = 'https://cf.farside.link/' + match[1] + window.location.pathname + window.location.search;
        window.location.replace(redirectUrl);
    } else if (googleMatch) {
        const tld = googleMatch[1];
        const searchQuery = window.location.search;
        if (searchQuery.startsWith('?q=')) {
            window.stop();
            const redirectUrl = 'https://cf.farside.link/searx/search' + searchQuery;
            window.location.replace(redirectUrl);
        }
    }
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant