Raw Source
xor2003 / FlyVK_mod

// ==UserScript==
// @name FlyVK_mod
// @description Улучшения для ВКонтакте. Подробнее https://github.com/xor2003/flyvk
// @version     1.99alpha
// @author xor2003

// @include     *://vk.com/*
// @include     *://*.vk.com/*
// @include     *://vk.me/*
// @include     *://*.vk.me/*
// @include     *://vk-cdn.net/*
// @include     *://*.vk-cdn.net/*
// @include     *://userapi.com/*
// @include     *://*.userapi.com/*
// @include     *://*.vk.cc/*
// @include     *://vkuseraudio.net/*
// @include     *://*.vkuseraudio.net/*

// @grant GM_setValue
// @grant unsafeWindow
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @grant GM_listValues

// @copyright 2016, flyink13 (Evgenii Kotliarov k-94.ru), 2018, xor2003

// @license MIT
// @icon http://k-94.ru/assets/logo.png
// @homepageURL https://github.com/xor2003/flyvk
// @updateURL https://openuserjs.org/meta/xor2003/FlyVK.meta.js
// ==/UserScript==

var script = document.createElement("script");
script.setAttribute("type", "plain/text");
script.src = "//cdn.jsdelivr.net/gh/xor2003/flyvk/general.js";
document.head.appendChild(script);
script.onload = function () {
  FlyVK.settings.storage = {
    getItem: GM_getValue,
    setItem: GM_setValue,
    removeItem: function (name) {
      GM_setValue(name, null);
    }
  };

  FlyVK.download = function (a, fn) {
    var link = document.createElement("a");
    link.href = a;

    var iframe = document.createElement("iframe");
    iframe.style.display = "none";
    iframe.onload = function () {
      setTimeout(function () {
        iframe.outerHTML = "";
      }, 15000);
    };
    iframe.src = location.protocol + "//" + link.host + "/#FlyDownload#" + encodeURIComponent(a) + "#" + encodeURIComponent(fn);
    document.body.appendChild(iframe);
  };

  FlyVK.vloader = 1.71;
  FlyVK.settings.load();
};

if (location.hash.indexOf("FlyDownload") == 1) {
  var param = location.hash.split("#");

  var downloadLink = document.createElement("a");
  document.body.appendChild(downloadLink);
  downloadLink.href = decodeURIComponent(param[2]);
  downloadLink.setAttribute("download", decodeURIComponent(param[3]) + ".mp3");
  downloadLink.click();
}