Greasy Fork is available in English.
context menu
Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta
// @require https://update.greasyfork.org/scripts/534404/1868038/contextmenu.js
;(() => {
if (window.self !== window.top) {
return;
}
const menus = [...GM_getValue('menus', []), ...[
{
title: "anki",
action: ankiHelper.addAnki,
key: "p"
},
{
title: 'qrcode',
action() {
const html = document.createElement('div');
html.innerHTML = createHtml(`
<style>
.qr-text{ width: 26vw; margin-bottom: 1vw; height: 2vw; font-size: 100%; }
.qr-img img{ margin: auto; max-width: 27vw }
</style>
<div class="qr-container">
<input type="text" name="qr-text" class="qr-text" value="${location.href}">
<div class="qr-img"></div>
</div>`);
const qr = new QRCode(html.querySelector('.qr-img'), {
text: location.href,
correctLevel: QRCode.CorrectLevel.L,
height: 365,
width: 365,
});
html.querySelector('.qr-text').addEventListener('change', function () {
this.value && qr.makeCode(this.value);
});
Swal.fire({
title: "<h3>qrcode</h3>",
html: html,
width: '32vw',
});
},
key: 'm'
},
{
title: "PDFJS",
action() {
const helperServerHost = GM_getValue('host', 'http://127.0.0.1:9999');
if (location.href.startsWith('file:///')) {
const path = location.href.replace('file:///', '');
const file = `${helperServerHost}/file?file=${path}`;
location.href = `${helperServerHost}/pdfjs/viewer.html?file=${file}`
return
}
location.href = `${helperServerHost}/pdfjs/viewer.html`;
},
key: "v"
},
...customizeMenu(location.href),
/*{
title: "sh",
action: {
cmd: "ls -l /var/log/!*.log",
},
key: "e",
path: "cmd",
call: (res) => {
console.log(res.response)
},
}*/
/*{
title: "env",
action: {
cmd: ["env","grep","wc"],
args: [],
"1": ["PATH"],
"2": ["-l"],
env: ["PATH=$PATH:/home/xing"]
},
key: "e",
path: "cmd",
call: (res) => {
console.log(res.response)
},
}*/
/*{
title: "ls",
action: {cmd: "ls", args: ["-l", "/"]},
key: "e",
path: "cmd",
call: (res) => {
console.log(res.response)
},
}*/
]];
function customizeMenu(url) {
return GM_getValue('fetch-items', []).filterAndMapX(fetchItem => {
const name = fetchItem['fetch-name'];
if (!name || !fetchItem['fetch-active']) {
return false;
}
let active = false;
if (fetchItem['url-scope']) {
for (const scope of fetchItem['url-scope'].split('||')) {
if (new RegExp(scope).test(url)) {
active = true;
break;
}
}
if (!active) {
return false;
}
}
if (!fetchItem['add-contextmenu']) {
active && superFetchHook.executeActions(name);
return false
}
return {title: name, action: () => superFetchHook.executeActions(name)};
});
}
PushContextMenu(...menus);
})();