Giter VIP home page Giter VIP logo

Comments (15)

ivan94fi avatar ivan94fi commented on June 3, 2024 1

Sorry @roedesh I missed the notifications for this post. I will test the new version and let you know. Thank you

from copyguard.

ivan94fi avatar ivan94fi commented on June 3, 2024 1

Hey thanks for the quick solution. Yes I think this fix might be an improvement.

However, looking at the logged "alteredClipboard" events that I included yesterday in my post, maybe this will not solve every problem.

I will test this code when I can and will let you know.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

Hi @Gitoffthelawn, glad you like the extension.

Would it be possible to display the before and after clipboard contents so the user can quickly see what changes were made by the site's JavaScript?

The thing is, you can already see the contents. The "before" is the text you have selected. The "after" you can just paste somewhere and see what it is.

How would you prefer to compare them?

from copyguard.

Gitoffthelawn avatar Gitoffthelawn commented on June 3, 2024

I'm thinking of a popup message box (or notification) that includes the before and after content displayed one right above the other.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

I think notifications could grow rather large, and might not even fit the screen, if the text selection is large enough.

Would a log page like I mentioned in #12 be a solution?

from copyguard.

Gitoffthelawn avatar Gitoffthelawn commented on June 3, 2024

Thanks. I'm going to put some thought to it.

from copyguard.

ivan94fi avatar ivan94fi commented on June 3, 2024

Hi!

Any plans on supporting this feature? It happens quite often that the pasted contents are identical to the copied ones, yet the extension prints a warning: it would be useful to see what is changed (maybe a space, somehow?)

I agree that sometimes the selected text would not fit the message. Maybe a button could be added to the notification: if clicked, a page with a diff is opened, to inspect the differences. I am not quite sure if it is doable: as of now the notifications appear in system dialogs, so maybe use a broswer-specific notification instead would be better. Again I don't know if such thing exists, I am just proposing some ideas.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

I'm currently working on a insight page feature, where you can see a log of all the warnings you have received, grouped per domain. These logs contain the before and after. This feature will be released somewhere next week.

It happens quite often that the pasted contents are identical to the copied ones, yet the extension prints a warning

Which warning do you get in those cases? That the clipboard was altered, or that there were hidden elements? If it is the latter, I'm also including a fix to ignore hidden elements that don't have text in them.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

I just released version 1.3.0 which includes the Insights feature and a fix for hidden elements that contain no text.

from copyguard.

ivan94fi avatar ivan94fi commented on June 3, 2024

Ok I am testing it and I still see some problems: I think the culprit is the difference in linux selections (primary and clipboard).

For example if I select the first line in this repo's changelog (without copying), the primary selection will contain the selected text and the clipboard will contain whatever was there:

clipboard:
(whatever was here)
primary:
All notable changes to this project will be documented in this file.

Then, when I copy the selected text, the selections will be synchronized:

clipboard:
All notable changes to this project will be documented in this file.
primary:
All notable changes to this project will be documented in this file.

Now, I think this might be the issue because I found lines like these in the log while messing around selecting and copying at random:

copyguard_clipboard_log

However sometimes it does not happen, and it is not fully reproducible.

Let me know if you need some more details.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

@ivan94fi Thanks for reporting.

Couple of questions/remarks:

  • Which browser were you using (including version)?
  • Which Linux distro were you using (including version)?
  • Also, maybe I'm misunderstanding your example, but that sounds like it's working correctly. The clipboard only changes AFTER you copy. Though the clipboard contents in your screenshot do look weird.

When you answered these questions I will fire up a VM and see if I can reproduce it.

from copyguard.

ivan94fi avatar ivan94fi commented on June 3, 2024
  • Browser: Chrome Version 98.0.4758.80 (Official Build) (64-bit)
  • Distro: Ubuntu 18.04
  • Yes the clipboard changes after copies, and that is expected. However the "primary" selection buffer (see for example this Unix StackExchange question) is changed even before copies, as soon as some text is selected. It may be that the comparison between the clipboard and the selection fails because the selection (thus the primary selection buffer) contains the newly selected text, while the clipboard still contains the older text.

I will try to make an example, but I am not sure if this can be the problem:

  1. Let's say that my clipboard buffer contains the text A. It is not relevant what the primary selection buffer contains at this point, as it is overwritten in the next step.
  2. Now I select the text B on a web page, so my primary selection buffer contains B, but the clipboard buffer still contains A.
  3. Now I copy the selected text (B) so that also the clipboard buffer will end up containing B as well.

The problem might happen in point 3. The primary selection buffer always contains B, but the clipboard buffer might still contain its older contents A, in case that the check on clipboard contents is done before the clipboard buffer is actually updated.

I don't know the inner workings of the selection mechanism for the browser, so my hypothesis could be wrong, but the symptoms seem to agree with this hypothesis.

Let me know if you need something else.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

Okay I am able to reproduce it sometimes, but only when I start a selection and then copy in quick succession.

Taking the following sentence as an example:

I don't know the inner workings of the selection mechanism for the browser, so my hypothesis could be wrong, but the symptoms seem to agree with this hypothesis.

Let's say I start selecting from the left to the right, and during selection I trigger a copy event. The data in the clipboard might be I don't know the inner workings of the selection mechanism for the browser, but the selection will end up being the entire sentence. Is this similar to the behaviour you are experiencing @ivan94fi ?

If so, then I have some ideas for a fix:

  • Add a small delay before getting the selection and checking it against the clipboard. This may allow the browser to load the full sentence into the clipboard.
  • Leverage the mousedown and mouseup events to wait for the selection to finish, before the allowing the copy event to fire.

from copyguard.

ivan94fi avatar ivan94fi commented on June 3, 2024

Is this similar to the behaviour you are experiencing @ivan94fi ?

Yes I can reproduce this too, but as you pointed out, the issue is a bit randomic. Sometimes it does not happen for quite a long time, sometimes almost always.

This could really be a synchronization problem. A small delay could fix this and would be fast to implement. Waiting on the events might be better, but how about selection with the keyboard? Maybe it is not so relevant after all.

from copyguard.

roedesh avatar roedesh commented on June 3, 2024

So the ideas I had won't work unfortunately, but I may have found a workaround.

In the background script I run the following if-statement: const isDifferent = clipboard != selection. This does not work on Linux sometimes, due to the buffer stuff you mentioned. So I was thinking that for Linux only I could add a few conditions:

const isDifferent = clipboard != selection || !clipboard.includes(selection) || !selection.includes(clipboard)

So in addition to the original condition, it also checks if the clipboard does not contain the selection, and vice versa.

I tested this change in Firefox, and now I can move around the selection while copying without triggering a notification. On websites where the clipboard data is actually changed with Javascript, a notification is still triggered.

See: https://github.com/roedesh/copyguard/compare/bug/linux-buffer

from copyguard.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.