Last active
October 24, 2022 01:52
-
-
Save jeffrey4l/aa9cdae0453cdfd0891c06e6f0303c40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Jeffrey4l Enhance | |
// @namespace https://gist.github.com/jeffrey4l/aa9cdae0453cdfd0891c06e6f0303c40/raw/Jeffrey4l-enhance.user.js | |
// @version 0.5.3 | |
// @description try to take over the world! | |
// @author Jeffrey4l | |
// @homepage https://gist.github.com/jeffrey4l/aa9cdae0453cdfd0891c06e6f0303c40/ | |
// @match *://*/* | |
// @grant GM_registerMenuCommand | |
// @grant GM_setClipboard | |
// ==/UserScript== | |
var _Enhance = { | |
getPageInfo(md = false) { | |
let url = document.location.href; | |
var titleElement = document.getElementsByTagName('title')[0] | |
var t = titleElement.text | |
// drop html entity | |
t = t.replace(/\&#.*;/, ''); | |
if (md){ | |
t = t.replace(/([_\[\]\|\n])/g, ""); | |
} | |
return [t, url]; | |
}, | |
registerMenu(){ | |
GM_registerMenuCommand("Copy as Plain", () => { | |
const [title, url] = this.getPageInfo(); | |
GM_setClipboard(`${title}\n${url}\n`); | |
}); | |
GM_registerMenuCommand("Copy as Markdown", () => { | |
const [title, url] = this.getPageInfo(true); | |
GM_setClipboard(`[${title}](${url})\n`); | |
}); | |
GM_registerMenuCommand("Copy as TiddlyWiki", () => { | |
const [title, url] = this.getPageInfo(true); | |
GM_setClipboard(`[[${title}|${url}]]\n`); | |
}); | |
GM_registerMenuCommand("Copy as TiddlyWiki List", () => { | |
const [title, url] = this.getPageInfo(true); | |
GM_setClipboard(`* [[${title}|${url}]]\n`); | |
}); | |
}, | |
init(){ | |
this.registerMenu() | |
} | |
}; | |
(function() { | |
'use strict'; | |
if (window.frames.length != parent.frames.length) { | |
return false; | |
} | |
_Enhance.init() | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment