视频记录

记录看过的视频并隐藏

Per 04-04-2024. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         视频记录
// @namespace    xywc-s
// @author       xywc-s
// @version      1.4.3
// @description  记录看过的视频并隐藏
// @match        https://spankbang.com/*
// @match        https://*.xvideos.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=spankbang.com
// @grant        GM_getResourceText
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @require      https://unpkg.com/[email protected]/notyf.min.js
// @resource     NotifyCSS https://unpkg.com/[email protected]/notyf.min.css
// @license MIT
// ==/UserScript==
/*jshint esversion: 6 */

const NotifyCSS = GM_getResourceText("NotifyCSS");
GM_addStyle(NotifyCSS);

const notyf = new Notyf({
    position: {
        x: 'right',
        y: 'top'
      }
});

const domain = location.host.split('.').at(-2)
switch (domain) {
  case 'spankbang':
    spankBangRecord()
    break;
  case 'xvideos':
    xvideosRecord();
    break;
  default: ''
    break;
}

function xvideosRecord() {
  class Button {
    constructor(id, el) {
      this.btn = document.createElement('button')
      this.btn.innerHTML = '<span class="icon-f icf-plus-square"></span>'
      this.btn.onclick = () => {
        const ids = GM_getValue('xvideos', [])
        ids.push(id)
        GM_setValue('xvideos', ids)
        notyf.success('记录成功')
        el?el.remove():this.btn.remove()
      }
      return this.btn
    }
  }

  const ids = GM_getValue('xvideos', [])
  const videoBox = document.querySelector('.mozaique')

  if (videoBox) {
    const videos = videoBox.children
    for (let video of videos) {
      const v_id = video.getAttribute('data-id')
      if (!v_id) {
        video.style.display = 'none';
      }
      if (ids.includes(v_id)) {
        video.style.display = 'none';
      } else {
        const title = video.children[1].children[0]
         if(title) title.prepend(new Button(v_id, video))
      }
    }
  }
  if(html5player){
    const v_id = html5player.id_video
    if(!ids.includes(v_id)){
      const bar = document.querySelector('#v-actions .tabs')
      bar.prepend(new Button(v_id))
    }
  }
}

function spankBangRecord() {
  const storage = localStorage.getItem('ids')

  const list = document.querySelectorAll('#container .video-list div.video-item')
  const v = document.querySelector('#video')

  listVideoRecord(list)
  if (v) {
      mainVideoRecord(v)
      document.querySelector('#video .right').style.display='none'
  }

  function mainVideoRecord(v) {
    const vid = v.getAttribute('data-videoid')
    const title = document.querySelector('#container .left h1')
    if (storage && storage.includes(vid)) {
      // 已记录
    } else {
      const a = document.createElement('a')
      a.innerHTML =
        '<svg class="i_svg i_star"><use xlink:href="/static/desktop/gen/universal.master.6.1.00d54069.svg#star"></use></svg>'
      a.title = '记录'
      a.style.cursor = 'pointer'
      a.onclick = () => {
        localStorage.setItem('ids', storage + ',' + vid)
        notyf.success('记录成功')
        a.remove()
      }
      title.append(a)
    }
  }

  function listVideoRecord(list) {
    list.forEach((item) => {
      const listVID = item.getAttribute('data-id')
      if (storage && storage.includes(listVID)) {
        item.style.display = 'none'
      } else {
        const btn = document.createElement('span')
        btn.classList.add('b')
        btn.innerHTML =
          '<svg class="i_svg i_plus-square"><use xlink:href="/static/desktop/gen/universal.master.6.1.00d54069.svg#plus-square"></use></svg>'
        btn.onclick = () => {
          localStorage.setItem('ids', localStorage.getItem('ids') + ',' + listVID)
          notyf.success('记录成功')
          btn.remove()
        }
        item.querySelector('.stats').append(btn)
        item.querySelector('.stats').children[0].remove()
      }
    })
  }
}