Skip to content

Instantly share code, notes, and snippets.

@ahnafnafee
Last active May 5, 2023 17:21
Show Gist options
  • Save ahnafnafee/50fc17d32a05ae1490e11e2e81060da7 to your computer and use it in GitHub Desktop.
Save ahnafnafee/50fc17d32a05ae1490e11e2e81060da7 to your computer and use it in GitHub Desktop.
Bypass Private Vimeo Video Restriction
// ==UserScript==
// @name Private Vimeo
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Script to redirect user to the private video
// @author You
// @match https://vimeo.com/*
// @match https://player.vimeo.com/video/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=vimeo.com
// @grant GM_addStyle
// ==/UserScript==
(function () {
"use strict";
function fetchLink() {
let match = /(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?/i.exec(window.location.href);
if (match) {
return "https://player.vimeo.com/video/" + match[1];
}
return window.location.href;
}
function ButtonClickAction(zEvent) {
let targetLink = fetchLink();
window.open(targetLink);
}
function createButton() {
var zNode = document.createElement("div");
zNode.innerHTML =
'<button id="private-button" type="button" class="iris_btn iris_btn--primary">' +
"View Private Video</button>";
zNode.setAttribute("id", "button-container");
document.querySelector(".exception_container").appendChild(zNode);
document
.getElementById("private-button")
.addEventListener("click", ButtonClickAction, false);
}
function init() {
// For the base vimeo page
if (
document.querySelector(".exception_container") &&
!(window.location.href.indexOf("player") > -1)
) {
createButton();
} else {
// For the player page, change referrer
if (
document.querySelector("h1") &&
document.querySelector("h1").innerHTML === "Sorry"
) {
}
}
}
// if the window is loaded, run init(), otherwise wait for it to load
if (document.readyState === "complete") {
init();
} else {
window.addEventListener("load", init, false);
}
})();
//--- Style our newly added elements using CSS.
GM_addStyle(`
#button-container {
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
}
#private-button {
cursor: pointer;
text-align: center;
display: inline-block;
}
`);

Setup Steps:

  • Install this extension first: Referer Manager
  • Add the following settings Extension Settings
  • Install the UserScript below using TamperMonkey
  • Now the webpage should show a button to view the private video like so image
  • Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment