I'm trying to retrieve an image stored in the clipboard using jQuery. So far, I've managed to find a solution which works perfectly using the onpaste event. But, as per the requirements I want the same functionality in a "button click" instead of a "paste" event. I've tried to put the same code in a button click event, but with no luck. What am I missing here?
Here's my jsfiddle
If possible please tell me how I can do the same in IE(10 & above) & Mozilla Firefox.
Exapmle : Demo Applet
As mozdev states, this feature should be available in FF since version 22.
https://developer.mozilla.org/en-US/docs/Web/Events/paste
"Caniuse" states that too btw: http://caniuse.com/#feat=clipboard
Maybe you have to use a browser prefix or the event attributes have different names. Is your event not fired in other browser than chrome or is it fired but you don't receive data?
EDIT:
Additionally 'paste' is an event, you can't trigger it manually by a button. (Well you can but it doesn't make any difference.) This wouldn't make sense because you can't directly access the clipboard for security reasons and therefore you don't have the data available. in browser. With a button you have to use the file-select and upload method, which i think needs a webserver in the back to handle the request, so no pure js solution.
Related
I am trying to scrap odd data by Pyppeteer from bet365 follow their UI flow and need for help.
The pages are just like this.
https://www.bet365.com/#/AC/B1/C1/D8/E123540970/F3/
If the match is outdated, just get into one of the matches that not in-played from following.
https://www.bet365.com/#/AS/B1/
For the collapsed button named "Handicap Result" at the bottom of the page, I can normally use my mouse cursor to click on it and make it expand and retrieve its data.
But when I tried to use Pyppeteer's click or javascript to do it, that is querySelector() and click(), it just weirdly failed.
Observing html and xhr after click(), it definitely triggered something and tried to do something, but the content just failed to shown.
I tried to click on different coordinates, key Enter and Space, click with delay, and all failed.
Could someone tell me how could I expand it use javascript?
Was I dissipating wrong events?
Thanks.
This is probably one way they use to avoid scraping.
U tested with pure JS direct from DevTools?
Bet365 its really, really hard to scrape. They use Cloudflare blocking and protection system (including AI to detect autonomous agent like Puppeteer, even if you use stealth mode).
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.com/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.
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).
There are numerous way through one can copy contents from Right Click protected sites
By disabling browser JavaScript in browser
Using Proxy Sites
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
view-source:Enable copy and paste for a site that doesn't allow it
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
I am using a web application and I want to change its behaviour for myself via Tampermonkey. The problem is, that the middle mouse click for opening a new tab doesn't work because the click event is overridden. I have no chance to change the application on server side! So the easiest would be to remove the event.
It is removing the event, when I am removing the event withing the Chrome Developer Tools manually via the remove button:
ChromeDevTools
The app is using jquery-1.11.1.min.js so I want to remove those events via JQuery.
HTML Snippet where the event is attached (also see the screenshot):
XYZ.
I have tried to remove the onclick part in the html and I removed the event via following javascript: (first of all in the Developer Console of Chrome):
$('a#id5214').unbind();
$('a#id5214').off();
But without success. Only removing it via the remove button in the Event Listernes Tab working fine (without any other step).
Am I missing some events when I am doing that via javascript?
You can try this way
$('#id5214').attr('onclick','').unbind('click');
.off() is reccomended and available from JQuery 1.7 and above.
If your document is valid (no duplicated IDs), you should remove "a" tag from selector, because it can cause really bad performance.
I want to write an Google Chrome extension to prevent a specific webpage to react on blur events.
I know how to do it for the javascript part : I inject some javascript in the page at runtime:"document_start" in order to overload the addEventListener method with my own function.
The problem is with flash parts on the page. Theses can use addEventListener(flash.events.Event.DEACTIVATE,deactivate_method_in_as3);
Of course I'd like to prevent the method call
So I have several questions :
Is it possible to set a security parameter somewhere to disallow Chrome to transmit focus related events to the application ?
Is it possible to modify 'on the fly' the swf file to remove or overide this handler (of course I have no control on that swf).
I also started to use the chrome.debugger.* and chrome.windows.* APIs because they can intercept events early. In that case I have a annoying message saying "tab is debugged by ..."
The swf has a similar handler for flash.events.Event.ACTIVATE so I can try to use it. But how to trigger it when the page is not focused ? (I tried to call focus() on it but it doesnt seems to work.
Any other idea welcome :)
Thanks for reading
I have an HTML <select> in many places in my application, and I want to replace it with a custom drop down. I have created the custom control which will replace the HTML <select> on DOM ready.
Now, I want to implement something that will disable/re-enable my new control if there is a Javascript disabling/enabling the original control without doing any changes in the application elsewhere except within the control.
How is it that I can capture the event of the HTML select control being disabled or enabled and attach some code to that? Is there any other way to do it?
UPDATE:
I got this thing working in IE7, Safari/Chrome but its not working in mozilla. Sample code in here http://jsfiddle.net/M73Wg/3/
This is a tricky one. Unfortunately (I believe) there is no straight answer. It comes down to: Yes you can do so by using JavaScripts DOMAttrModified event listener, but it's not cross-browser compatible.
Here are a few resources that might help you:
Detect Attribute Changes with jQuery (possible solution)
Is it possible to listen for changes to an object's attributes in JavaScript?
Listen for changes of checked/disabled in jQuery
Finally used timeout only http://jsfiddle.net/8EtJK/6/
DOMAttrModified is not working in mozilla
Regards,
SJ