app.logos.com trying to get the copy function to work

For support with specific websites

Moderator: trava90

Forum rules
Please always mention the name/domain of the website in question in your topic title.
Please one website per topic thread (to help keep things organized). While behavior on different sites might at first glance seem similar, they are not necessarily caused by the same.

Please try to include any relevant output from the Toolkit Error Console or the Developer Tools Web Console using the following procedure:
  1. Clear any current output
  2. Navigate or refresh the page in question
  3. Copy and paste Errors or seemingly relevant Warnings into a single [ code ] block.
User avatar
andyprough
Keeps coming back
Keeps coming back
Posts: 805
Joined: 2020-05-31, 04:33

app.logos.com trying to get the copy function to work

Unread post by andyprough » 2024-06-19, 00:45

Please always mention the name/domain of the website in question in your topic title.
app.logos.com

Please try to include any relevant output from the Toolkit Error Console or the Developer Tools Web Console using the following procedure:

1) Clear any current output
2) Navigate or refresh the page in question
3) Copy and paste Errors or seemingly relevant Warnings into a single [ code ] block.

Code: Select all

document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler.
I've been wanting to use the text copy function on the app.logos.com Biblical research site to copy text from the site. It seems to have its text displayed via some javascript and the copy function seems to be run by javascript. You no longer need to log into an account there to try to use the copy function - anyone can go to the site, which will bring up John 1 from the ESV, and try to copy a few words from that page using the page's copy function.

I get this error when trying to copy:
document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler.

I did a bit of research and found a Mozilla wiki page that seemed to deal with the problem by adding the following four lines to a user.js:

Code: Select all

user_pref("capability.policy.policynames", "allowclipboard");
user_pref("capability.policy.allowclipboard.sites", "https://app.logos.com/");
user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
http://kb.mozillazine.org/Granting_Java ... _clipboard

I tried this in a clean new profile with no extensions or themes on the latest Pale Moon 33.2.0 today. However I don't know if user.js actually works with Pale Moon, as I haven't tried it previously. Does user.js function on Pale Moon the same way it does on Firefox, like with the arkenfox user.js? That's the user.js file I have the most experience with using and placing into the Firefox profile folder. I created a user.js with these lines and placed it in ~/.moonchild productions/pale moon/ inside the folder for the profile I was using, and restarted Pale Moon and tried again and did not get any change - no ability to use the Logos copy function.

Just wondering if anyone had any thoughts. This would be convenient for me to be able to do text copy from this site, as the site otherwise works well on Pale Moon but has not worked as well for reading on Firefox. However it's not an urgent matter, I can live without the text copy function if needed.

I appreciate any feedback.

Here's a screenshot of the text copy button:
2024-06-18_19-42.png

User avatar
FranklinDM
Add-ons Team
Add-ons Team
Posts: 592
Joined: 2017-01-14, 02:40
Location: Philippines
Contact:

Re: app.logos.com trying to get the copy function to work

Unread post by FranklinDM » 2024-06-19, 01:28

I don't think those capability.policy.allowclipboard prefs exist anymore.

That site does use the clipboard-polyfill npm package, however. It might be worth investigating the code that it uses in the unminified form.

User avatar
andyprough
Keeps coming back
Keeps coming back
Posts: 805
Joined: 2020-05-31, 04:33

Re: app.logos.com trying to get the copy function to work

Unread post by andyprough » 2024-06-19, 02:51

FranklinDM wrote:
2024-06-19, 01:28
That site does use the clipboard-polyfill npm package, however.
Oh, and that clipboard-polyfill github page says its old and deprecated. So Logos is using the wrong method?

I don't suppose there would be any easy way for me to make it work that you'd be able to share?

User avatar
adoxa
Fanatic
Fanatic
Posts: 218
Joined: 2019-03-16, 13:26
Location: Qld, Aus.
Contact:

Re: app.logos.com trying to get the copy function to work

Unread post by adoxa » 2024-06-20, 14:17

I tried hacking it to use navigator.clipboard.writeText directly (it would normally use write, but it wants ClipboardItem, as well). It would copy up to five words, but not six or more. No idea what's going on there.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36054
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: app.logos.com trying to get the copy function to work

Unread post by Moonchild » 2024-06-20, 16:08

document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler.
This is an anti-abuse measure. "This is why we can't have nice things". https://dvcs.w3.org/hg/editing/raw-file ... s-commands
Basically, bad sites would abuse clipboard writing from background scripts/non-user-interactive scenarios to blank or overwrite the clipboard. Therefore it was necessary to restrict this to short-running, user-activated contexts only when allowing it from custom event handlers.

User avatar
andyprough
Keeps coming back
Keeps coming back
Posts: 805
Joined: 2020-05-31, 04:33

Re: app.logos.com trying to get the copy function to work

Unread post by andyprough » 2024-06-20, 16:30

adoxa wrote:
2024-06-20, 14:17
I tried hacking it to use navigator.clipboard.writeText directly (it would normally use write, but it wants ClipboardItem, as well). It would copy up to five words, but not six or more. No idea what's going on there.
Actually, that's not a bad start, as about 2/3 of the time I'm just copying one or two words in Greek or Hebrew from the site. Could you possibly show me how you did that?

And I can tell you what's different after 5 or 6 words - it's an academic research site, so after the first few words it automatically adds an academic citation to whatever text you are copying. You can even configure which citation method you want added on in the site's settings.

User avatar
adoxa
Fanatic
Fanatic
Posts: 218
Joined: 2019-03-16, 13:26
Location: Qld, Aus.
Contact:

Re: app.logos.com trying to get the copy function to work

Unread post by adoxa » 2024-06-21, 01:54

Guess I should have looked a little closer, as it was indeed the citation causing the problem - turn that off and the copy worked fine. If you do want the citation I'll have to muck about a bit more, but otherwise here's a Modify HTTP Response filter to enable copy.

Code: Select all

[["app.logoscdn.com",["/dist\\/logos\\./",["/U=async\\(e,t\\)=>\\{[\\s\\S]*?\\}catch/","U=async(e,t)=>{try{await navigator.clipboard.writeText(e.plainText||e);return!0}catch"]]]]

User avatar
andyprough
Keeps coming back
Keeps coming back
Posts: 805
Joined: 2020-05-31, 04:33

Re: app.logos.com trying to get the copy function to work

Unread post by andyprough » 2024-06-21, 04:10

adoxa wrote:
2024-06-21, 01:54
Guess I should have looked a little closer, as it was indeed the citation causing the problem - turn that off and the copy worked fine. If you do want the citation I'll have to muck about a bit more, but otherwise here's a Modify HTTP Response filter to enable copy.

Code: Select all

[["app.logoscdn.com",["/dist\\/logos\\./",["/U=async\\(e,t\\)=>\\{[\\s\\S]*?\\}catch/","U=async(e,t)=>{try{await navigator.clipboard.writeText(e.plainText||e);return!0}catch"]]]]
Wow that worked great, and you are right, turning off the citation-copy setting on the web page allows full text copy. This is awesome, thanks so much! Where would one learn to write these Modify HTTP Response filters? justoff gives a bare amount of info on his github page, and I've tried simple filters in the past with limited success.

User avatar
adoxa
Fanatic
Fanatic
Posts: 218
Joined: 2019-03-16, 13:26
Location: Qld, Aus.
Contact:

Re: app.logos.com trying to get the copy function to work

Unread post by adoxa » 2024-06-21, 06:20

I suppose one would need a knowledge of Javascript, in order to know what to modify. Otherwise it's just simply replace what doesn't work with what does. :)

Post Reply