惡魔旅館警告器

惡魔旅館警告器! No more 惡魔旅館

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name     惡魔旅館警告器
// @version  0.2
// @grant    none
// @include https://www.ptt.cc/bbs/Gossiping/*
// @license MIT
// @description 惡魔旅館警告器! No more 惡魔旅館
// @namespace https://greasyfork.org/users/916025
// ==/UserScript==
console.log("惡魔旅館警告器")


// 黑名單列表
const alertList = [
  "DevilHotel",
]



const pathname = window.location.pathname.replace("/bbs/Gossiping/", "")

if (pathname.startsWith("M")){
	const pushUseridArray = Array.from(document.querySelectorAll(".push-userid"))
  const blockPushUserid = pushUseridArray.filter((e)=> alertList.indexOf(e.innerText) != -1)
  const author = document.querySelector(".article-metaline>.article-meta-value").innerText.replace(/\(.+\)/, "")
  const warring = (alertList.indexOf(author) != -1) || (blockPushUserid.length > 0)
  
  let blockedRichcontent = []
  
  if (warring) {
  	// set warring
  }
  blockPushUserid.map((e) => {
    const nextSibling = e.offsetParent.nextSibling
    if (nextSibling.classList.contains("richcontent")) {
    	blockedRichcontent.push(nextSibling)
      e.style.color = "red"
    }
  })
  console.log(blockedRichcontent)
  
  blockedRichcontent.map((e) => e.style.display = "none")
  
} else {
	const authorDivs = document.querySelectorAll(".author")

  for (const e of authorDivs){
    if ( alertList.indexOf(e.innerText) != -1) {
      e.style.color = "red"
      e.offsetParent.style.border = "1px solid red"
    }
  }
}