Closed ericpa06 closed 2 years ago
Copy as plain text is usefull, I use this fuction frequently. 1.replace the context menuitem copy use addMenuPlus.uc.js with config:
page([{
id: 'context-copy-new',
'data-l10n-href': 'textActions.ftl',
'data-l10n-id': 'text-action-copy',
condition: 'select',
text: "%s",
insertAfter: 'context-copy'
}])
css("#context-copy{ display: none !important }");
If you want to format the text yourself, replace text: "%s",
with
oncommand: function(event) {
let text = addMenu.convertText("%SEL%");
// add text format codes here
//
addMenu.copy(text);
},
2.replace ctrl + c, save follow code to CopyPlainTextHelper.uc.js
// ==UserScript==
// @name CopyPlainTextHelper.uc.js
// @author Ryan
// @include main
// @version 0.0.1
// @compatibility Firefox 72
// @shutdown window.CopyPlainTextHelper.destroy()
// @homepage https://github.com/benzBrake/FirefoxCustomize
// ==/UserScript==
(function () {
if (window.CopyPlainTextHelper)
window.CopyPlainTextHelper.destroy();
window.CopyPlainTextHelper = {
init: function () {
document.addEventListener('keyup', this, false);
},
destroy: function () {
document.removeEventListener('keyup', this, false);
delete window.CopyPlainTextHelper;
},
handleEvent(event) {
if (event.key === "c" && event.ctrlKey) {
event.preventDefault();
let text = addMenu.convertText("%SEL%");
// add text format codes here
//
addMenu.copy(text);
}
},
}
setTimeout(function () {
window.CopyPlainTextHelper.init();
}, 3000)
})()
Thank you so much! It worked like a charm. I end up playing a little bit with the addMenuPlus.uc.js script, and it occurred to me one thing, It has nothing do with my original request, but would it be possible to add another speed option on the speed submenu on Firefox? Like this for instance:
I usually watch videos on faster speeds, and sometimes even more than 2X, I was wondering if would be possible to add like 3X or even 4X speeds in this submenu when interacting with this sort of content?
Demo for add 5x speed
page([{
id: 'context-media-playbackrate-500x',
type: 'radio',
label: '5x',
oncommand: "gContextMenu.mediaCommand('playbackRate', 5.0);",
insertAfter: 'context-media-playbackrate-200x'
}])
Thank you so much! You are a genius! It worked. Just some last minor nitpicks, if I may, it's a esthetic one, I noticed that the script doesn't have any margin at the first time it runs, like this:
Although the margin comes back once you enable it.. Also when you enable this special speed, it works, but when you go back to the normal/default speeds, the check-mark on the special speed, in this case 5x, remains on (as if it was still active even though it's not anymore, the speed goes back to the normal one as well). Like this for instance:
https://user-images.githubusercontent.com/6937720/184800516-9ee26674-703c-4090-960d-8998b6642f8b.mp4
Those are such minor issues that I even ashamed feel mentioning, it's purely aesthetic triggering my OCD or so 😂 Again, thank you so much again.
page([{
id: 'context-media-playbackrate-500x',
type: 'radio',
check: 'false',
name: 'playbackrate',
label: '5x',
oncommand: "gContextMenu.mediaCommand('playbackRate', 5.0);",
insertAfter: 'context-media-playbackrate-200x',
onshowing: function () {
this.classList.remove("menuitem-iconic");
this.removeAttribute("onshowing");
}
}])
Perfect! Thank you a lot! •ᴗ•
Hi, it's me again. As always, sorry to bother. I was wondering if it would be possible to create a script that makes Firefox, by default, to always paste text as plain text (therefore getting ready of all formatting details)? There are extensions that do that, such as, several actually: https://addons.mozilla.org/en-US/firefox/addon/copy-plaintext/? https://addons.mozilla.org/en-US/firefox/addon/simple-plain-text-copy/? https://addons.mozilla.org/en-US/firefox/addon/copy-as-plain-text-webext/?
But those extension, as far as I know, none of them change the original paste functionality/behavior, they just add a new functionality, a new hotkey and new context menu entry that do that. And I was wondering if would be possible to simply change firefox default behavior? I dig around on about:config and didn't find any tweak that does this. Apparently there was some talk on bugzilla about implementing this functionality a decade ago or so, but the idea didn't move forward I guess.
https://bugzilla.mozilla.org/show_bug.cgi?id=273008
Again, I'm noob as hell, so I have no idea about how feasible would be this. As always thank you very much :+1: