Skip to content

Instantly share code, notes, and snippets.

@Kenya-West
Created June 26, 2020 12:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kenya-West/7fdd53f4c7c3a5175e890b5af22057ae to your computer and use it in GitHub Desktop.
Save Kenya-West/7fdd53f4c7c3a5175e890b5af22057ae to your computer and use it in GitHub Desktop.
instagram-native-player

Instagram native player

Description

This little script replaces Instagram's player with the native one built in browser. Using this script, you are able to save the video, disable/enable sound and do as many stuff as your browser can.

Requirements

The scripts requires Tampermonkey or any other script runner.

Specs

The script is written using ES5 constructions. Tested only in Chrome v57.

// ==UserScript==
// @name Instagram-native-player
// @namespace Kenya-West
// @version 0.3
// @description This little script replaces Instagram's player with the native one built in browser
// @author Kenya-West
// @include *instagram.com*
// @grant none
// ==/UserScript==
(function () {
'use strict';
window.onload = getRid;
window.addEventListener('popstate', getRid);
window.addEventListener('hashchange', getRid);
//a hook for a url path change
var _wr = function (type) {
var orig = history[type];
return function () {
var rv = orig.apply(this, arguments);
var e = new Event(type);
e.arguments = arguments;
window.dispatchEvent(e);
return rv;
};
};
history.pushState = _wr('pushState'), history.replaceState = _wr('replaceState'); //Chrome only feature... perhaps
window.addEventListener('replaceState', function (e) {
getRid();
});
function getRid() {
if (document.querySelector("._c2kdw")) document.querySelector("._c2kdw").remove();
if (document.querySelector("._80v0r")) document.querySelector("._80v0r").remove();
if (document.querySelector("._7thjo")) document.querySelector("._7thjo").remove();
if (document.querySelector("._j12ff")) document.querySelector("._j12ff").remove();
if (document.querySelector("._sajt6")) document.querySelector("._sajt6").remove();
var video = document.querySelector("._l6uaz");
if (video && video.hasAttribute("controls")) {
video.removeAttribute("controls");
} else if (video) {
video.setAttribute("controls", "controls");
}
video.play();
console.log("Successfully replaced Instagram videoplayer with a native one"); //production::enable
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment