您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Export and import NUS mods
当前为
// ==UserScript== // @name NUSMods Export Planner // @namespace http://tampermonkey.net/ // @version 2025-03-02 // @description Export and import NUS mods // @author Someone // @match https://nusmods.com/planner // @icon https://www.google.com/s2/favicons?sz=64&domain=nusmods.com // @run-at document-end // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; var plannerFunctions = window.plannerFunctions = {}; plannerFunctions.importPlanner = function () { if (confirm("Are you sure to overwrite the existing planner with new data?")) { var i0 = document.createElement('input'); var f0; i0.type = 'file'; i0.onchange = e => { f0 = e.target.files[0]; try { // setting up the reader var reader = new FileReader(); reader.readAsText(f0,'UTF-8'); // here we tell the reader what to do when it's done reading... reader.onload = readerEvent => { var content = readerEvent.target.result; // this is the content! console.log( content ); localStorage.setItem("persist:planner", content); window.location.reload(); } } catch (error) { console.error(error); alert(error); } } i0.click(); } } plannerFunctions.exportPlanner = function () { var plannerObj = localStorage.getItem("persist:planner"); function download(content, fileName, contentType) { var a = document.createElement("a"); var file = new Blob([content], {type: contentType}); a.href = URL.createObjectURL(file); a.download = fileName; a.click(); } download(plannerObj, 'planner.json', 'text/json'); } plannerFunctions.clearPlanner = function () { if (confirm("Are you ABSOLUTELY SURE that you want to remove all existing data from the planner?")) { localStorage.removeItem("persist:planner"); window.location.reload(); } } const delay = ms => new Promise(res => setTimeout(res, ms)); window.addEventListener('load', async function () { let c = document.createElement("ul"); c.classList += 'R2Qt7mz2 list-unstyled'; c.innerHTML = '<li><button type="button" class="btn btn-block btn-outline-primary" onclick="plannerFunctions.exportPlanner();">Export Planner</button></li><li><button onclick="plannerFunctions.importPlanner();" class="btn btn-block btn-outline-primary">Import Planner</button></li><li> <button onclick="plannerFunctions.clearPlanner();" class="btn btn-block btn-outline-primary" type="button">Clear Planner</button></li>'; await delay(2000); document.getElementsByTagName('header')[0].after(c); }); })();