Created
July 20, 2018 14:46
-
-
Save larvata/95ff5aa1d18e2298741290116718b38c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name instagram easy save | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.instagram.com/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
/* | |
const hook = (xhr) => { | |
console.log('new image loaded', xhr) | |
document.querySelectorAll('img[srcset]')[0].parentElement.nextElementSibling | |
Array.from(document.querySelectorAll('img[srcset]')).forEach((img) => { | |
if (img.parentElement && img.parentElement.nextElementSibling) { | |
img.sizes = '99999px'; | |
img.parentElement.nextElementSibling.remove(); | |
console.log('done:', img); | |
} | |
}) | |
} | |
window.XMLHttpRequest = ((win, hook) => { | |
const XMLHttpRequestOrig = win.XMLHttpRequest | |
return class XMLHttpRequestSpy{ | |
constructor(){ | |
const xhr = new XMLHttpRequestOrig(); | |
xhr.onreadystatechange = () => { | |
if (xhr.readyState === 4) { | |
hook(xhr); | |
} | |
} | |
return xhr; | |
} | |
} | |
})(window, hook); | |
*/ | |
setInterval(() => { | |
Array.from(document.querySelectorAll('img[srcset]')).forEach((img, idx) => { | |
if (!img.dataset.deleted && img.parentElement && img.parentElement.nextElementSibling) { | |
img.sizes = '99999px'; | |
img.dataset.deleted = true; | |
img.parentElement.nextElementSibling.style.zIndex = -1; | |
} | |
}) | |
Array.from(document.querySelectorAll('video')).forEach((video) => { | |
if(video.dataset.deleted) return; | |
video.dataset.deleted = true; | |
video.controls = true; | |
if (video.parentElement && | |
video.parentElement.parentElement && | |
video.parentElement.parentElement.parentElement && | |
video.parentElement.parentElement.parentElement.nextElementSibling && | |
video.parentElement.parentElement.parentElement.nextElementSibling.nextElementSibling){ | |
console.log( video.parentElement.parentElement.parentElement.nextElementSibling) | |
const lst = [ | |
video.parentElement.parentElement.parentElement.nextElementSibling, | |
video.parentElement.parentElement.parentElement.nextElementSibling.nextElementSibling, | |
].forEach(c => c.remove()) | |
} | |
}) | |
}, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment