Code Monkey home page Code Monkey logo

Comments (6)

keijukainen avatar keijukainen commented on May 8, 2024 1

A javascript bookmarklet would accomplish this. However, it would be session based and would require the user to manually activate it. You could publish the bookmarklet as a link on your github readme page. Users could then right click the link and bookmark the code to save it to their toolbar. Anytime they wanted to activate it they could simply click the bookmark on their toolbar. It would be cross-browser compatible so you wouldn't need a separate chrome and firefox extension. Since it's session based the code would automatically stop once they closed the tab or browser or navigated to a different url. You'd have to implement a global variable and set an interval to constantly check for new links since youtube content can change without reloading the page. Firefox users would have to add one new pref to about:config in order to show protocol handler popup.

overview

  1. test domain of page loaded in focused tab. if not youtube.com then exit.
  2. set global variable to keep track of total video/playlist links
  3. create an array of all links on page
  4. loop through array and compare each url to a regex pattern to determine which links point to video/playlist.
  5. if match is found then prepend href with a new 'freetube:' protocol, stop propagation of click event and update total.
  6. set interval of 3 seconds and call the same function at each interval to count total video links. compare current total to global variable total. if number is different then process urls again to add freetube protocol.

Example:
Go to about:config in firefox.
Type network.protocol into filter box.
Right click and create new boolean pref using name below.

network.protocol-handler.expose.freetube

Set pref to false.
Go to a youtube video page (https://www.youtube.com/watch?v=VPI9E-wNK8s)
Paste the code below into your address bar.
You'll have to retype javascript: at the beginning of url. Firefox automatically removes it when you paste a javascript url.
Press enter to apply the url changes.
Click any video url and you should see a protocol handler popup.
Choose location of freetube and check the 'remember my choice' box.
Tested on linux using ff 60.0.2

javascript: var aTags = document.documentElement.getElementsByTagName('a'); for (let i = 0; i < aTags.length; ++i) { if (aTags[i].href.search(/\?v=[\w\-]{11}/) > -1 && aTags[i].href.substr(0,9) != 'freetube:') { aTags[i].setAttribute('onclick', 'event.stopPropagation();'); aTags[i].setAttribute('href', 'freetube:' + aTags[i].href); } } alert(aTags.length + ' links processed');

from freetube.

PrestonN avatar PrestonN commented on May 8, 2024

This is something that I've been wanting to do. I have a general idea on how to do it but it's going to take a little bit of research on my part to get this working. The functionality will most likely have to come from a Chrome/Firefox extension to work.

from freetube.

dimqua avatar dimqua commented on May 8, 2024

Is it possible to handle them on a system level, at least on Windows or Linux?

from freetube.

PrestonN avatar PrestonN commented on May 8, 2024

Not that I'm aware of. You can make specific links in a browser accomplish this without a browser extension, but you would still need something to convert YouTube links to these redirect links. I understand that it's not the most ideal, but a browser extension is the most practical solution to this.

from freetube.

PrestonN avatar PrestonN commented on May 8, 2024

@keijukainen you might be interested in taking a look at freetube-redirect. It's not as robust as your solution but it should be a much more user friendly solution. I would love to have your help towards improving it if you are willing to do so.

Setting up the freetube: protocol is actually done automatically if you install the .deb or .exe of FreeTube. This might work for other installations but I haven't been able to test them out. This should make it much easier as a user to get this up and running.

Let's continue this conversation over at the freetube-redirect repository.

from freetube.

PrincessMiki avatar PrincessMiki commented on May 8, 2024

@keijukainen you might be interested in taking a look at freetube-redirect. It's not as robust as your solution but it should be a much more user friendly solution. I would love to have your help towards improving it if you are willing to do so.

Setting up the freetube: protocol is actually done automatically if you install the .deb or .exe of FreeTube. This might work for other installations but I haven't been able to test them out. This should make it much easier as a user to get this up and running.

Let's continue this conversation over at the freetube-redirect repository.

I installed freetube from .deb and see no 'freetube protocol' option

from freetube.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.