Remove AO3 Bookmarks

Remove all your bookmarked fics when browsing ao3

目前為 2023-09-05 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Remove AO3 Bookmarks
// @namespace   none
// @license     MIT
// @match       https://archiveofourown.org/*
// @grant       none
// @version     1.1
// @author      @zhbluvs
// @description Remove all your bookmarked fics when browsing ao3
// ==/UserScript==

async function getBookmarksOnePage(num){
    var work_ids = [];
    var res2 = await fetch('https://archiveofourown.org/users/INSERT_USERNAME_HERE/bookmarks?page='+num)
    var stringweb = res2.text().then(r => new DOMParser().parseFromString(r, "text/html"))
    .then(r => {
        var outer = r.body.getElementsByClassName("bookmark blurb group");
        //console.log(outer);
        //console.log(outer.length);
        for(let i = 0; i < outer.length; i++){
            var inner = outer[i].getElementsByClassName("heading")[0].innerHTML;
            var search = inner.search(/\d/)
            var temp = inner.substring(search);
            var work_id = temp.substring(0, temp.indexOf('"'));
            work_ids.push(work_id);
        }
        let works = Array.from(document.getElementsByClassName("blurb"))
        works.forEach(work => {
            let curr_id = work.id.substring(work.id.indexOf("_") + 1);
            if (work_ids.includes(curr_id)) {
                work.style.display = 'none'
            }
        })
    })
}

async function getBookmarks(){
    'use strict';
    var res = await fetch('https://archiveofourown.org/users/centerz/bookmarks')
    var getpages = res.text().then(r => new DOMParser().parseFromString(r, "text/html"))
        .then(async r => { let str = r.body.getElementsByTagName("h2")[0].innerHTML;
                     let idx = str.indexOf("of");
                     let idx2 = str.indexOf("Bookmarks");
                     let num_works = Number(str.substring(idx + 3, idx2));
                     var pages = Math.floor(num_works / 20) + 1;
                     for(let i = 1; i <= pages; i++) {
                        getBookmarksOnePage(i);
                        await new Promise(r => setTimeout(r, 5000));
                     }
                   }
           );
}


function hideWorks()
{
  'use strict';

  getBookmarks();

}

hideWorks()