Kobo Detrashify

Removes the really trashy novels from Kobo

当前为 2019-07-23 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name     Kobo Detrashify
// @description Removes the really trashy novels from Kobo
// @version  1
// @grant    none
// @include https://kobo.com/*
// @include https://*.kobo.com/*
// @namespace https://greasyfork.org/users/319769
// ==/UserScript==

// Are we in edit mode?
let url = new URL(window.location);
let edit = url.searchParams.get('edit');
const EDIT_MODE = edit != null;
console.log(EDIT_MODE);

// Check and see if we should update our list
let myStorage = window.localStorage;

let authorSet = myStorage.getItem('KD-authors');
console.log(authorSet);
if (authorSet == null || true) {
  console.log('help');
  authorSet = [
    'Victoria Pinder',
		'Nina Levine',
    'Ramona Gray',
    'Dale Mayer',
    'Donna Grant',
    'Kendall Ryan',
    'Rebecca Zanetti',
    'Alyssa Drake',
    'Lori Foster',
    'Vella Day',
    'Elizabeth Kelly',
    'Meghan March',
    'Blair Babylon',
    'Tessa Layne',
    'Bethany Lopez',
    'Lynn Raye Harris',
    'Lane Lynn Vale',
    'Lani Lynn Vale',
    'S.E. Smith',
    'Carly Phillips',
    'Kylie Gilmore',
    'Manda Collins',
    'Katie Reus',
    'K.A. Linde',
   	'Cynthia Wright',
    'Vi Keeland',
    'Natasha Madison',
    'Adriana Anders',
    'Kelly Bowen',
    'Joanna Shupe',
    'Sophie Barnes',
    'Elizabeth Hoyt',
    'Maya Rodale'
    ];
  myStorage.setItem('KD-authors', JSON.stringify(authorSet));
  authorSet = new Set(authorSet);
} else {
	authorSet = new Set(JSON.parse(authorSet));
}


function addAuthor() {
  console.log("asdf");
	console.log("add author!", this);
}



deletThis(document.querySelectorAll('.item-container'));
deletThis(document.querySelectorAll('.book'));

function deletThis(books) {
  for (let i = 0; i<books.length; i++) {
    let author = books[i].querySelector('.contributor-name');
    if (author == null) {
      continue;
    }

    let authorName = JSON.parse(author.getAttribute('data-track-info'))['author'];
    // console.log(authorName);
    if (authorSet.has(authorName)) {
      console.log('UR A BITCH', authorName);
      books[i].remove();
    } else if (EDIT_MODE) {
      console.log("asdf");
      let element = document.createElement('button');
      element.setAttribute('onClick', addAuthor);
      element.setAttribute('value', 'Add author (value)');
      element.textContent = "Add author";
      author.insertAdjacentElement('afterend', element);
    }
  }
}