admin管理员组

文章数量:1304167

First off, I want to say that I very little knowledge of coding so please bear with me. I'm trying to paste in a site that doesn't allow it. This is the link to the javascript that they used to block it, .js?v=1.3

A friend of mine is helping me with it and he suggested that I put this in the javascript console in the DevTools of Google Chrome,

handler = function(e){ e.stopImmediatePropagation(); return true; }
document.querySelector('#conversation-content .conversation-message-text').addEventListener('keyup', handler, true)
document.querySelector('#conversation-content .conversation-message-text').addEventListener('input', handler, true)

This does solve the problem but it creates another issue. It seems that it interferes with this section of the javascript that I have linked to,

* Function to update the messagebox. (Enable/disable send button,
 * change the color class, update the counter)
 * @return  void

So what would happen is that when a message is typed in the textbook, there's a character counter at the top which shows how many characters are written. When 80 characters(I think it's 80) are typed, the send button will be enabled so that I can send the message. However, with the javascript code that my friend suggested that I used, it stops the counter from working altogether so the send button never gets highlighted.

Is there any way around this? Please let me know if further clarifications are needed since it's the first time I'm asking a question of this nature.

First off, I want to say that I very little knowledge of coding so please bear with me. I'm trying to paste in a site that doesn't allow it. This is the link to the javascript that they used to block it, https://mychatdashboard./js/messages.js?v=1.3

A friend of mine is helping me with it and he suggested that I put this in the javascript console in the DevTools of Google Chrome,

handler = function(e){ e.stopImmediatePropagation(); return true; }
document.querySelector('#conversation-content .conversation-message-text').addEventListener('keyup', handler, true)
document.querySelector('#conversation-content .conversation-message-text').addEventListener('input', handler, true)

This does solve the problem but it creates another issue. It seems that it interferes with this section of the javascript that I have linked to,

* Function to update the messagebox. (Enable/disable send button,
 * change the color class, update the counter)
 * @return  void

So what would happen is that when a message is typed in the textbook, there's a character counter at the top which shows how many characters are written. When 80 characters(I think it's 80) are typed, the send button will be enabled so that I can send the message. However, with the javascript code that my friend suggested that I used, it stops the counter from working altogether so the send button never gets highlighted.

Is there any way around this? Please let me know if further clarifications are needed since it's the first time I'm asking a question of this nature.

Share Improve this question asked Mar 23, 2019 at 15:16 darksidedarkside 311 gold badge1 silver badge1 bronze badge 0
Add a ment  | 

4 Answers 4

Reset to default 2

The JavaScript you're entering into the DevTools console is defining a function named handler and then adding it as an event handler for keyup and input events for a field on the page you're viewing (presumable the chat window textbox).

The way that the handler is defined and attached prevents other events from firing (such as those that enable the send button when you've typed enough characters).

For this sites (and I haven't been able to test it) instead of the code you've used you could try running this in the DevTools console (once the page is loaded):

restrictCopyPasteByKeyboard = function () { return true; };

This should redefine the function that's preventing you from using paste (I can't test it out because I can't access that site).

A quick way of doing this is to enable the designMode in Chrome or Firefox.

  1. To open the console window, hit F12 or right-click and select inspect, then navigate to the console tab.
  2. document.designMode = "on" paste the following snippet.

There are numerous way through one can copy contents from Right Click protected sites

  1. By disabling browser JavaScript in browser
  2. Using Proxy Sites
  3. By Using the source code of the site

Disabling JavaScript in Browsers [Google Chrome] In Chrome browser, you can quickly disable JavaScript by going to settings. See the screenshot for better explanation: screenshot

Through Viewing Source Code f you have to copy the specific text content and you can take care of HTML tags, you can use browser view source options. All the major browser give an option to source of the page, which you can access directly using the format below or by right click. Since, right click is out of question here, we will simply open chrome browser and type: view-source: before the post URl Like

  1. view-source:Enable copy and paste for a site that doesn't allow it

  2. Press ctrl+u

And find the paragraph or text you want to copy and then paste it into any text editor.

I'm sure there are many ways of restricting user's ability to copy/paste. In my experience, it's always been a JS function that you can overwrite.

Slight variations of the below have always worked for me:

document.getElementById("#ElementWithDisabledPaste").onpaste = null

本文标签: javascriptEnable copy and paste for a site that doesn39t allow itStack Overflow