Skip to content

Instantly share code, notes, and snippets.

@jeffrey4l
Last active October 24, 2022 01:52
Show Gist options
  • Select an option

  • Save jeffrey4l/aa9cdae0453cdfd0891c06e6f0303c40 to your computer and use it in GitHub Desktop.

Select an option

Save jeffrey4l/aa9cdae0453cdfd0891c06e6f0303c40 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Keepass Enhance
// @namespace https://gist.github.com/jeffrey4l/aa9cdae0453cdfd0891c06e6f0303c40
// @version 0.4
// @description try to take over the world!
// @author Jeffrey4l
// @match *://baidu.com/*
// @grant GM_registerMenuCommand
// @grant GM_setClipboard
// ==/UserScript==
var Enhance = {
}
(function() {
'use strict';
if (window.frames.length != parent.frames.length) {
return false;
}
var title = undefined;
var mappings = {
"abc.com": "abc site",
};
function fullTitle(){
var titleElement = document.getElementsByTagName('title')[0]
title = titleElement.text
if (titleElement === undefined){
return
}
var founded=false;
for (var url in mappings) {
if (window.location.host.indexOf(url) != -1) {
titleElement.text += " - " + mappings[url]
founded = true
break;
}
}
if (!founded){
titleElement.text += " - " + window.location.host
}
}
function fnGetInfo(md = false, tid=false) {
let url = document.location.href;
var t = title
if (md){
t = t.replace(/([_\[\]\|])/g, "");
}
return [title, url];
}
GM_registerMenuCommand("复制", () => {
const [title, url] = fnGetInfo();
GM_setClipboard(`${title}\n${url}\n`);
});
GM_registerMenuCommand("复制为Markdown", () => {
const [title, url] = fnGetInfo(true);
GM_setClipboard(`[${title}](${url})\n`);
});
GM_registerMenuCommand("复制为TiddlyWiki", () => {
const [title, url] = fnGetInfo(true);
GM_setClipboard(`[[${title}|${url}]]\n`);
});
GM_registerMenuCommand("复制为TiddlyWiki list", () => {
const [title, url] = fnGetInfo(true);
GM_setClipboard(`* [[${title}|${url}]]\n`);
});
fullTitle()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment