Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name NewGrounds Video Download Button (Simple)
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Send a fetch request to Newgrounds asking for the info to that video (using the credentials stored in the browser).
- // @author XenoTheStrange@jami.net
- // @match https://www.newgrounds.com/portal/view/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=newgrounds.com
- // @grant none
- // ==/UserScript==
- (function(){
- 'use strict';
- var obj;
- var command = `fetch(\"https://www.newgrounds.com/portal/video/VIDEOID\", {
- \"credentials\": \"include\",
- \"headers\": {
- \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0\",
- \"Accept\": \"application/json, text/javascript, */*; q=0.01\",
- \"Accept-Language\": \"en-US,en;q=0.5\",
- \"X-Requested-With\": \"XMLHttpRequest\",
- \"Sec-Fetch-Dest\": \"empty\",
- \"Sec-Fetch-Mode\": \"cors\",
- \"Sec-Fetch-Site\": \"same-origin\"
- },
- \"referrer\": \"https://www.newgrounds.com/portal/view/VIDEOID\",
- \"method\": \"GET\",
- \"mode\": \"cors\"
- })
- .then(res => res.json())
- .then(data => obj = data)
- .then(() => createButton(obj.sources["1080p"][0].src))`
- var tmp = eval(command.replaceAll("VIDEOID", document.location.href.split("/")[5]))
- function createButton(string){
- console.log(string)
- var button = document.createElement("a")
- button.href = string
- button.innerHTML = "Download"
- document.querySelector(".ng-video-controls").appendChild(button)
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement