la-image-extractor

copy image source in hitomi.la notomi.la to clipboard

От 29.09.2018. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name                la-image-extractor
// @name:zh-CN          la 图片地址复制
// @description         copy image source in hitomi.la  notomi.la to clipboard
// @description:zh-CN   复制 hitoma.la  notomi.la 图片链接到剪贴板
// @version             0.1.4
// @author              jferroal
// @license             GPL-3.0
// @require             https://greasyfork.org/scripts/31793-jmul/code/JMUL.js?version=209567
// @include             https://hitomi.la/reader/*
// @include             https://nozomi.la/tag/*
// @run-at              document-idle
// @namespace           https://greasyfork.org/users/34556-jferroal
// ==/UserScript==

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function () {
  const ADAPOST = false
  const NUMBER_OF_FRONTENDS = 2
  // create button to click
  const btn = document.createElement('div')
  btn.innerText = 'Copy Sources'
  btn.style.textAlign = 'center'
  btn.style.width = '120px'
  btn.style.lineHeight = '40px'
  btn.style.backgroundColor = 'skyblue'
  btn.style.color = 'white'
  btn.style.cursor = 'pointer'
  btn.style.borderRadius = '8px'
  btn.style.boxShadow = '0px 0px 8px 4px rgba(0, 0, 0, .2)'
  btn.style.position = 'fixed'
  btn.style.right = '80px'
  btn.style.bottom = '80px'
  document.body.appendChild(btn)
  // bind copy event
  btn.addEventListener('click', () => {
    const href = window.location.href
    const isHitomi = /hitomi/gi.test(href)
    // prepare str2Paste
    let [imgSrcSelector, titleSelector] = ['.tag-list-img', 'h1']
    if (isHitomi) {
      imgSrcSelector = '.img-url'
      titleSelector = 'title'
    }
    let srcs = Array.from(document.querySelectorAll(imgSrcSelector))
    let title = document.querySelector(titleSelector).innerText
    if (isHitomi) {
      title = title.split(' | ')[0]
      const mat = /\/\d*(\d)\.html/.exec(window.location.href)
      let lv = mat && parseInt(mat[1], 10)
      if (!lv || Number.isNaN(lv)) {
        btn.removeEventListener('click', () => null)
        btn.style.display = 'none'
        return
      }
      const magic = ADAPOST ? 'a' : String.fromCharCode(((lv === 1 ? 0 : lv) % NUMBER_OF_FRONTENDS) + 97)
      srcs = srcs.map(s => s.innerText.replace('//g.hitomi.la', `https://${magic}a.hitomi.la`))
    } else {
      srcs = srcs.map(s => s.src.replace('//tn', '//i').split('.').slice(0, 4).join('.'))
    }
    const str2paste = `${title}\n${srcs.join('\n')}\n${'= ='.repeat(20)}`
    const el = document.createElement('textarea')
    el.value = str2paste
    document.body.appendChild(el)
    el.select()
    document.execCommand('copy')
    document.body.removeChild(el)
  })
})()

},{}]},{},[1]);