lisovski / PIN Fixed Bugs

// ==UserScript==
// @name         PIN Fixed Bugs
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Fixed some bugs for comfortable work 
// @author       Lisovski
// @grant        GM_getResourceText
// @resource     jQuery https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @match        https://*.pin7.ru/*
// @match        https://*.arenda-piter.ru/*
// @match        https://*.internet-piter.ru/*
// @copyright 2019, Lisovski (https://openuserjs.org/users/lisovski)
// @updateURL https://openuserjs.org/meta/lisovski/PIN_Fixed_Bugs.meta.js
// @license MIT
// ==/UserScript==

(function() {
  var head = document.getElementsByTagName('head')[0];

  var script = document.createElement('script');
  script.id = 'jquery';
  script.type = 'text/javascript';

  var jQuery = GM_getResourceText('jQuery');

  script.innerHTML = jQuery;
  head.appendChild(script);

    script_inserted = document.getElementById('jquery');
    if (script_inserted != null) {
        $ = unsafeWindow.$;
        start();
    }
})();

function start() {
var imgs = [],
  counter = 1;

if (location.href.indexOf('pin7.ru') > -1 && jQuery(".st01 .br_img img").length > 0) {
  var id = jQuery('.tdm_11 em').text(),
    date = 0;

  jQuery(".st01 .br_img img").each(function () {
    var img = jQuery(this).attr('src').split('&');
    date = img[1].replace('ff=', '').replace('20', '');
    var file = img[0].replace('lupa.php?fn=' + id + '_f', '').replace('.jpg', '');
    imgs.push(file);
  });

  jQuery('.tdm_08').append('<br><a style="display:inline-block;padding: 10px 20px;border:2px solid #f00;color:#f00;background:#fff;border-radius:5px;margin: 20px;font-size: 15px;" onclick="jQuery(this).attr(\'style\',jQuery(this).attr(\'style\') + \'opacity:0.5;\').text(\'Ожидайте...\');" href="https://vspb.pro/download.php?id=' + id + '&date=' + date + '&images=' + imgs.join(',') + '" download>Скачать фото архивом</a>');
}

if (location.href.indexOf('arenda-piter.ru') > -1 && jQuery(".link_block .swiper-wrapper img").length > 0) {
  var id = jQuery('.trm_01').attr('id').replace('idtr', ''),
    date = 0;

  jQuery(".link_block .swiper-wrapper img").each(function () {

    if (jQuery(this).attr('data-src') !== undefined)
      var img = jQuery(this).attr('data-src').split('&');
    else
      var img = jQuery(this).attr('src').split('&');

    date = img[1].replace('ff=', '').replace('20', '');
    var file = img[0].replace('/lupa_min.php?fn=' + id + '_f', '').replace('.jpg', '');
    imgs.push(file);
  });

  jQuery('.link_block .tbl04 .st03').before('<br><a style="display:inline-block;padding: 10px 20px;border:2px solid #f00;color:#f00;background:#fff;border-radius:5px;margin: 20px;font-size: 15px;" onclick="jQuery(this).attr(\'style\',jQuery(this).attr(\'style\') + \'opacity:0.5;\').text(\'Ожидайте...\');" href="https://vspb.pro/download.php?id=' + id + '&date=' + date + '&images=' + imgs.join(',') + '" download>Скачать фото архивом</a>');
}

if (location.href.indexOf('internet-piter.ru') > -1 && jQuery(".link_block .swiper-wrapper img").length > 0) {
  var id = jQuery('.trm_01').attr('id').replace('idtr', ''),
    date = 0;

  jQuery(".link_block .swiper-wrapper img").each(function () {

    if (jQuery(this).attr('data-src') !== undefined)
      var img = jQuery(this).attr('data-src').split('&');
    else
      var img = jQuery(this).attr('src').split('&');

    date = img[1].replace('ff=', '').replace('20', '');
    var file = img[0].replace('/lupa_min.php?fn=' + id + '_f', '').replace('.jpg', '');
    imgs.push(file);
  });

  jQuery('.link_block .tbl04 .st03').before('<br><a style="display:inline-block;padding: 10px 20px;border:2px solid #f00;color:#f00;background:#fff;border-radius:5px;margin: 20px;font-size: 15px;" onclick="jQuery(this).attr(\'style\',jQuery(this).attr(\'style\') + \'opacity:0.5;\').text(\'Ожидайте...\');" href="https://vspb.pro/download.php?id=' + id + '&date=' + date + '&images=' + imgs.join(',') + '" download>Скачать фото архивом</a>');
};
}