imomoe

add next

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         imomoe
// @version      0.0.1
// @include      http://www.imomoe.io/player/*
// @include      https://api.xiaomingming.org/cloud/*
// @description  add next
// @namespace    https://greasyfork.org/users/164996a
// ==/UserScript==
const m = document.querySelector('iframe[src]')
const c = document.querySelector('div.dplayer-icons-right')
const dp = unsafeWindow.dp
if (dp) {
  dp.play()
  const next = () => {
    window.top.postMessage('next', '*')
  }
  c.insertAdjacentHTML(
    'afterbegin',
    "<button id='next' class='dplayer-quality dplayer-icon dplayer-quality-icon'>下一集</button>"
  )
  const b = document.querySelector('#next')
  b.addEventListener('click', next)
  window.addEventListener('message', e => {
    if (e.data === 'next unavailable') {
      b.remove()
    }
  })
  dp.on('ended', next)
} else if (m) {
  m.focus()
  let a, b
  for (let i of document.querySelectorAll('.movurls')) {
    a = [...i.querySelectorAll('a')]
    b = a.findIndex(i => i.href === window.location.href)
    if (b === -1) continue
    a = a[b + 1]
    if (a) a = a.href
    break
  }
  document
    .querySelectorAll('.movurls a')
    .forEach(i => i.setAttribute('target', '_self'))
  window.addEventListener('message', e => {
    if (e.data === 'next') {
      window.location.href = a
    }
  })
  ;(async () => {
    await new Promise(r => setTimeout(r, 5000))
    if (!a) m.contentWindow.postMessage('next unavailable', '*')
  })()
}