1337x - Torrent page improvements

Makes titles longer on the torrent page and optionally enables the detail box when available.

目前為 2018-01-14 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         1337x - Torrent page improvements
// @namespace    NotNeo
// @version      1.3
// @description  Makes titles longer on the torrent page and optionally enables the detail box when available.
// @author       NotNeo
// @include      http*://1337x.to/account
// @include      http*://1337x.to/torrent/*
// @include      http*://1337x.st/account
// @include      http*://1337x.st/torrent/*
// @include      http*://1337x.ws/account
// @include      http*://1337x.ws/torrent/*
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// ==/UserScript==

var usingDetailBox = true; //setting to default
//GM_deleteValue("usingDetailBox");
if( GM_getValue("usingDetailBox") != null ) {
	usingDetailBox = GM_getValue("usingDetailBox"); //overriding with saved settings if there is one
}

if(window.location.href.indexOf("1337x.to/account") >= 0 || window.location.href.indexOf("1337x.st/account") >= 0 || window.location.href.indexOf("1337x.ws/account") >= 0) { //if on settings page
    document.getElementById("settings").innerHTML = '<br><input type="checkbox" value="1" name="useDetail" id="useDetailCheckbox" style="transform: scale(1.5);"> <label for="useDetailCheckbox">Show detail box for torrents, when available.</label><br>' + document.getElementById("settings").innerHTML;
    document.getElementById("useDetailCheckbox").checked = usingDetailBox; //settings checkbox checked value to saved value (or default, if none are saved)
    document.getElementById("useDetailCheckbox").onchange = function() { //on value change
        usingDetailBox = document.getElementById("useDetailCheckbox").checked; //settings current value to the the new
        GM_setValue("usingDetailBox", usingDetailBox); //saving current value
    };
}

var title = document.getElementsByTagName("title")[0].textContent;
title = title.substring(9, title.length-16);
var titleArea = document.getElementsByClassName("box-info-heading")[0];
if(titleArea.getElementsByTagName("span").length == 2 && title.length > 100) {
    title = title.substring(0, 100) + "...";
} else if(titleArea.getElementsByTagName("span").length >= 3 && title.length > 85) {
    title = title.substring(0, 85) + "...";
}
titleArea.getElementsByTagName("h1")[0].textContent = title;

if(usingDetailBox) {
    var realDetailBox = document.getElementsByClassName("torrent-detail")[0];
    if(!(realDetailBox.offsetWidth > 0 && realDetailBox.offsetHeight > 0)) { //if realDetailBox is not visible, make own
        var datHTML = realDetailBox.innerHTML;
        document.getElementsByClassName("torrent-category-detail")[0].innerHTML += '<div class="torrent-detail clearfix" style="display: inline-block; position: relative; margin-top: 10px; width: 100%;">'+datHTML+'</div>';
    }
}