download from redpilled.eu

Circumvents the download blocker on redpilled.eu by supplying the correct user agent.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        download from redpilled.eu
// @namespace   abdrool
// @include     https://redpilled.eu/*
// @include     http://redpilled.eu/*
// @include     http://176.96.138.175/*
// @grant       GM_download
// @grant       GM_addStyle
// @grant       GM_xmlhttpRequest
// @version     1.0
// @author      abdrool
// @description Circumvents the download blocker on redpilled.eu by supplying the correct user agent.
// @require     https://cdnjs.cloudflare.com/ajax/libs/filesize/6.3.0/filesize.min.js
// @require     http://code.jquery.com/jquery-latest.js
// ==/UserScript==


let customCss = `
#progress {
  position: fixed;
  background: rgb(38, 42, 50);
  padding: 15px;
  border: ;
  border-top-left-radius: 10px;
  right: 0%;
  bottom: 0%;
  font-size: 12px;
  line-height: 20px;
}

#progress:first-child::after {
  content: "Changing page will abort downloads!";
  color:red;
  font-weight: bold;
  padding-left: 10px;
}

#progress span {
    margin-left: 10px;
    margin-right: 10px;
}
`
GM_addStyle(customCss);

$("tbody a").click(function(e) {
  var path = new URL(e.target.href).pathname;
  if (!path.endsWith("/")) {
    e.preventDefault();
    let downloadId = Math.floor(Math.random() * 100000);
    let filename = path.split('/').pop();
    
    var progressBox = $("#progress");
    if (!progressBox.length) {
      $("body").prepend("<div id='progress'></div>");
      progressBox = $("#progress");
    }
    progressBox.append("<div class='download' id='" + downloadId +"'><span class='name'>" + filename + "</span><span class='status'></span></div>");
    
    var headers = {"User-Agent": "GMod"}
    
    GM_xmlhttpRequest({
      url: e.target.href,
      method: "HEAD",
      headers: headers,
      onload: function(response) {
        if (response.status != 200) {
          $("#" + downloadId + " .status").text(response.status + " " + response.statusText);
          return;
        }
        
        var a = GM_download({
          url: e.target.href,
          name: e.target.text,
          headers: headers,
          onerror: function(err){ console.log(err.error) },
          onprogress: function(progress){
            $("#" + downloadId + " .status").text(filesize(progress.loaded) + " / " + filesize(progress.total));
          },
          saveAs: true,
        });
      },
    });
  }
});