export image from myppt and lurl

Derive image to the bottom of web page and fill the password gennerated by update date

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         export image from myppt and lurl
// @name:zh-TW   從myppt和lurl中導出圖片以及填寫密碼
// @name:en.     export image from myppt and lurl
// @namespace    normaltool
// @version      0.1.3
// @description:zh-TW  導出myppt和lurl的圖片在網頁的底部,並且自動填寫日期密碼
// @description  Derive image to the bottom of web page and fill the password gennerated by update date
// @author       jw23
// @match        https://*.myppt.cc/*
// @match        https://*.lurl.cc/*
// @license     MIT
// ==/UserScript==

(function () {
    'use strict';
    var images = [];
    let deaultpassword = function(cssSelector){
        try{
        return /\d{4}-(\d{2}-\d{2})/.exec(document.querySelector(cssSelector).textContent)[1].replace('-','')
        }catch(e){
            console.log("error in password:",e)
        }
    }
    if (document.URL.indexOf('myppt.cc') != -1) {
        fillPassword('#pasahaicsword',deaultpassword('.form-group.has-feedback'))
        let links = document.querySelectorAll("link[rel=preload]");
        for (let link of links) {
            let imagesLinks = link.getAttribute('href');
            images.push(imagesLinks)
        }
    } else if (document.URL.indexOf('lurl.cc')) {
        fillPassword('#password',deaultpassword('.form-group.has-feedback'))
        let scripts = document.querySelectorAll('.gameIn script')
        for (let script of scripts) {
            if (script.textContent.indexOf('canvas_img') != -1) {
                let res = /https:\/\/.+.lurl.cc\/.+g/.exec(script.textContent)
                images.push(res[0])
            }
        }
    }

    for (let image of images) {
        let img = document.createElement("img");
        img.src = image
        img.style.width = "100%"
        document.body.appendChild(img);
    }
})();
// 从URL中提取文件名
function getFilename(url) {
    return url.substring(url.lastIndexOf('/') + 1);
}
function fillPassword(selector, password) {

    let input = document.querySelector(selector)
    if (input !== null) {
        input.value = password;
        // document.querySelector('#main_fjim60unBU').click()
    }
}