说明
因为MoviePilot每次重启都要重新登陆,而且浏览器又不能自动填充账号密码,我比较懒不想输账号密码所有我写了这个破脚本。
使用教程
安装本脚本后,打开Tampermonkey插件的管理面板找到本脚本-操作-编辑按钮
找到以下代码将内容改成你自己的:
//配置区
//注意上面的注释的 @match 也要改成你的MoviePilot的IP地址不要加端口
let uname = "账号"; //MoviePilot账号
let upassword = "密码";//MoviePilot密码
let MoviePilotHost = "http://192.168.5.100:3000";//MoviePilot地址ip+端口 后缀不需要加 /
以及将@match
的url地址改成你MoviePilot的地址,不用加端口,然后ctrl+s保存即可
当你的MoviePilot需要登录时本脚本会自动登录不用任何操作
代码
// ==UserScript==
// @name MoviePilot自动登录
// @namespace https://www.muooy.com/
// @version 2024-11-20
// @description 因为MoviePilot每次重启都要重新登陆,而且浏览器又不能自动填充账号密码,我比较懒不想输账号密码所有我写了这个脚本。
// @author You
// @match http://192.168.5.100
// @icon https://www.google.com/s2/favicons?sz=64&domain=5.2
// @grant none
// @require https://unpkg.com/axios/dist/axios.min.js
// @license GNU GPLv3
// ==/UserScript==
(function () {
'use strict';
//配置区
//注意上面的注释的 @match 也要改成你的MoviePilot的IP地址不要加端口
let uname = "账号"; //MoviePilot账号
let upassword = "密码";//MoviePilot密码
let MoviePilotHost = "http://192.168.5.100:3000";//MoviePilot地址ip+端口 后缀不需要加 /
//不懂的不要动以下代码
var currentUrl = window.location.href;
let intervalId;
let vueRouter;
var index = 0;
function waitForVue() {
return new Promise((resolve) => {
const checkVue = () => {
if (window.Vue && window.Vue.prototype.$router) {
vueRouter = window.Vue.prototype.$router;
resolve();
} else {
setTimeout(checkVue, 1000);
}
};
checkVue();
});
}
function checkUrlChange() {
const newUrl = window.location.href;
if (!newUrl.includes('login')) {
clearInterval(intervalId);
currentUrl = newUrl;
startMonitoring();
} else {
info11();
}
}
function info11() {
let formData = new FormData();
formData.append('username', uname);
formData.append('password', upassword);
axios.post(MoviePilotHost + '/api/v1/login/access-token', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(function (response) {
axios.get(MoviePilotHost + '/api/v1/user/config/Layout', {
headers: {
'Authorization': 'Bearer ' + response.data.access_token
}
}).then((responsea) => {
localStorage.setItem('moviepilot', '{"auth":{"token":"' + response.data.access_token + '","remember":true,"superUser":' + response.data.super_user + ',"userID":' + response.data.user_id + ',"userName":"' + response.data.user_name + '","avatar":"' + response.data.avatar + '","originalPath":"/dashboard","level":' + response.data.level + '}}');
axios.get(MoviePilotHost + '/api/v1/user/config/Dashboard', {
headers: {
'Authorization': 'Bearer ' + response.data.access_token
}
}).then((responsea) => {
location.reload();
});
});
})
.catch(function (error) {
console.error('Error posting data:', error);
window.history.go(0);
});
}
function startMonitoring() {
intervalId = setInterval(checkUrlChange, 1000);
}
function setupRouteChangeListeners() {
const pushState = history.pushState;
history.pushState = function (state) {
pushState.apply(history, arguments);
checkUrlChange();
};
window.addEventListener('hashchange', checkUrlChange);
window.addEventListener('popstate', checkUrlChange);
}
async function navigateToNewUrl() {
await waitForVue();
const newPath = '/dashboard';
vueRouter.push(newPath);
}
window.onload = startMonitoring();
setupRouteChangeListeners();
console.log("本脚本出生于2024-11-20,功能原创,请勿盗版!博客:https://www.muooy.com")
})();
Greasy Fork地址:https://greasyfork.org/zh-CN/scripts/518136-moviepilot%E8%87%AA%E5%8A%A8%E7%99%BB%E5%BD%95
© 版权声明
THE END
暂无评论内容