juejinBackgroundImage

修改掘金背景图,设置自己喜欢的背景图!

目前為 2023-06-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name         juejinBackgroundImage
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  修改掘金背景图,设置自己喜欢的背景图!
// @author       wjh
// @match        https://*
// @match        https://*/*
// @icon         https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/849e3902e63a42cea93abb448cb0bb0f~tplv-k3u1fbpfcp-watermark.image
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.2.1/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 图片路径
    let imgUrl = window.localStorage.getItem('imgUrl') || 'https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9d58e69aaefa4aa59fdd61f1a58ede84~tplv-k3u1fbpfcp-watermark.image'
    let uploadBox = "<div id='uploadBox' style='position:fixed;top:80px;right:20px;background:rgba(255,255,255,0.5);padding: 10px;'><input style='width:66px;' type='file' name='' id='files'></div>"
    //let juejin = document.getElementById('juejin');
    //juejin.style.backgroundImage = "url("+ imgUrl +")"

    $('#juejin').css('backgroundImage',`url(${imgUrl})`);
    $('#juejin').css('backgroundSize',`100%`);

    $('body').append(uploadBox);


    $("#files").change(function(e) {
        var myform = new FormData();
        myform.append('app_key','469F2FD4742AA1E75C23D1A4E51468B8');
        myform.append('file',$('#files')[0].files[0]);
        //图片上传
        $.ajax({
            url:'https://hn216.api.yesapi.cn/api/App/CDN/UploadImg',
            type: "POST",
            data: myform,
            contentType: false,
            processData: false,
            success: function (data) {
                if(data.ret === 200){
                    imgUrl = data.data.https_url
                    window.localStorage.setItem('imgUrl',imgUrl)
                    $('#juejin').css('backgroundImage',`url(${imgUrl})`);
                }else{
                    alert(data.msg)

                }
            },
            error:function(data){
                console.log(data)
            }
        })
    })

    // Your code here...
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址