您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
This script adds two buttons to the bookmarks page. One button will export the list of titles in your bookmarks, the other will import a list of titles and overwrite your bookmarks.
当前为
// ==UserScript== // @name Asurascans bookmark saver // @namespace TestScript // @author Sieyk // @grant none // @license MIT // @match https://www.asurascans.com/bookmarks/ // @noframes // @require https://openuserjs.org/src/libs/ls18502857770.gmail.com/FileSaver.js // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js // @run-at document-end // @version 1.0 // @description This script adds two buttons to the bookmarks page. One button will export the list of titles in your bookmarks, the other will import a list of titles and overwrite your bookmarks. // ==/UserScript== (function () { "use strict"; window.addEventListener('load', () => { $("body").append ( ` <input id="filePick" type="file" hidden=true> ` ); addButton('Save Bookmarks', saveBookmarks, '7%') addButton('Import Bookmarks', importBookmarks, '4%') }) function addButton(text, onclick, posY, cssObj) { cssObj = cssObj || {position: 'absolute', bottom: posY, left:'4%', 'z-index': 3} let button = document.createElement('button'), btnStyle = button.style document.body.appendChild(button) button.innerHTML = text button.onclick = onclick Object.keys(cssObj).forEach(key => (btnStyle[key] = cssObj[key])) return button } function saveBookmarks() { var blob = new Blob([localStorage.getItem("bookmark")], { type: "text/plain;charset=utf-8" }); saveAs(blob, "bookmarks.txt") } async function importBookmarks() { // open file picker const input = event.srcElement.previousElementSibling.previousElementSibling; try { input.value = ""; input.showPicker(); console.debug(input.value); while (input.value == "") { await new Promise(r => setTimeout(r, 100)); }; } catch(error) { window.alert(input); return } console.debug(input.files); var reader = new FileReader(); reader.readAsText(input.files[0]); while (reader.readyState != 2) { await new Promise(r => setTimeout(r, 100)); } try { var arr = JSON.parse(reader.result); } catch(error) { window.alert("Invalid data type for bookmarks! Must be an Array."); return } if (Array.isArray(arr)) { localStorage.setItem("bookmark", reader.result); window.location.reload(); } else { window.alert("Invalid data type for bookmarks! Must be an Array."); return } } }());