Nyaa Auto Open Preview Image

Nyaa auto open first image host

Stan na 17-09-2018. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Nyaa Auto Open Preview Image
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Nyaa auto open first image host
// @author       Yich
// @match        https://sukebei.nyaa.si/view/*
// @grant          GM_openInTab
// @grant       GM_addStyle
// @grant       GM_getResourceText
//@require https://code.jquery.com/jquery-3.3.1.min.js
//@require https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js
// @resource    customCSS https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css
//@require https://use.fontawesome.com/releases/v5.0.8/js/solid.js
//@require https://use.fontawesome.com/releases/v5.0.8/js/fontawesome.js
//@run-at  document-start
/**************************************
如果無法使用,請在捷徑加入這段  "--allow-running-insecure-content"
記得要有空白和括號
修改時關閉chrome所有instance
允許載入不安全的JS程式碼 allow mix content
****************************************/
// ==/UserScript==


 var meta = document.createElement('meta');
meta.httpEquiv = "Content-Security-Policy";
meta.content = "upgrade-insecure-requests";
document.getElementsByTagName('head')[0].appendChild(meta);

var fancyboxType = 'iframe';

window.onload = function() {
    'use strict';
    var newCSS = GM_getResourceText("customCSS");
    GM_addStyle(newCSS);

    //取得description區塊的html
    var html = $("#torrent-description").html();
    var rawHtml = decodeEntities(html);
    //找出區塊裡的連結
    var reg = /((?:\w+):\/\/([\w@][\w.:@-]+)\/?[\w\.?=%&=\-@\/$,]*)/g;
    var url;
    while (url = reg.exec(rawHtml)) {
        if(!url[1].includes('offkab')){
            GM_openInTab( url[1], true );
            break;
        }
    }



    


};


//url decode
function decodeEntities(encodedString) {
    var textArea = document.createElement('textarea');
    textArea.innerHTML = encodedString;
    return textArea.value;
}