Advertisement
XenoTheStrange

Newgrounds Video Download Button (1080p ONLY)

Jun 8th, 2022 (edited)
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         NewGrounds Video Download Button (Simple)
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Send a fetch request to Newgrounds asking for the info to that video (using the credentials stored in the browser).
  6. // @author       XenoTheStrange@jami.net
  7. // @match        https://www.newgrounds.com/portal/view/*
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=newgrounds.com
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function(){
  13.     'use strict';
  14.     var obj;
  15.     var command = `fetch(\"https://www.newgrounds.com/portal/video/VIDEOID\", {
  16.    \"credentials\": \"include\",
  17.    \"headers\": {
  18.        \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0\",
  19.        \"Accept\": \"application/json, text/javascript, */*; q=0.01\",
  20.        \"Accept-Language\": \"en-US,en;q=0.5\",
  21.        \"X-Requested-With\": \"XMLHttpRequest\",
  22.        \"Sec-Fetch-Dest\": \"empty\",
  23.        \"Sec-Fetch-Mode\": \"cors\",
  24.        \"Sec-Fetch-Site\": \"same-origin\"
  25.    },
  26.    \"referrer\": \"https://www.newgrounds.com/portal/view/VIDEOID\",
  27.    \"method\": \"GET\",
  28.    \"mode\": \"cors\"
  29. })
  30.  .then(res => res.json())
  31.  .then(data => obj = data)
  32.  .then(() => createButton(obj.sources["1080p"][0].src))`
  33.    var tmp = eval(command.replaceAll("VIDEOID", document.location.href.split("/")[5]))
  34.  
  35.    function createButton(string){
  36.        console.log(string)
  37.        var button = document.createElement("a")
  38.        button.href = string
  39.        button.innerHTML = "Download"
  40.        document.querySelector(".ng-video-controls").appendChild(button)
  41.    }
  42. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement