PTP freeleech highlight & Button

highlights freeleech torrents and add a button to list them

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        PTP freeleech highlight & Button
// @description highlights freeleech torrents and add a button to list them
// @match       https://passthepopcorn.me/*
// @version     1.2.1
// @run-at      document-idle
// @license	    GPL3
// @author      SH3LL
// @namespace https://greatest.deepsurf.us/users/762057
// ==/UserScript==

function main(){
  // add button
  let top_menu = document.getElementsByClassName("main-menu__list");
  let li = document.createElement("li"); li.className="main-menu__item";
  let a = document.createElement("a"); a.href="https://passthepopcorn.me/torrents.php?action=advanced&freetorrent=1"; a.innerText="FL"; a.style.color="yellow";
  li.append(a); top_menu[0].append(li);
  
  
  // color lines
  if(window.location.href.includes("https://passthepopcorn.me/torrents.php?id")){
    
    let rows = document.getElementsByClassName("group_torrent group_torrent_header")
    for(let row of rows){
      if(row.innerText.includes("Freeleech")) {row.children[0].children[2].style.color = "yellow";continue}
      if(row.innerText.includes("Neutral Leech")) {row.children[0].children[2].style.color = "cyan";continue}
    }
    
  }else{
    
    let rows = document.getElementsByClassName("basic-movie-list__torrent-row")
    for(let row of rows){
      if(row.innerText.includes("Freeleech") && row.innerText.includes("✿")) {row.children[0].children[1].children[1].style.color = "yellow"; continue;}
      if(row.innerText.includes("Freeleech")) {row.children[0].children[1].children[0].style.color = "yellow"; continue;}
      if(row.innerText.includes("Neutral Leech") && row.innerText.includes("✿")) {row.children[0].children[1].children[1].style.color = "cyan"; continue;}
      if(row.innerText.includes("Neutral Leech")) {row.children[0].children[1].children[0].style.color = "cyan"; continue;}
    }
  }
  
  return 0
}

main();