Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop extensions/add ons like grammarly on contenteditable editors

We are making contenteditable editor. Wondering how to stop extensions like grammarly (if enabled) on editor page using javascript as these extensions insert their own html in the editor itself. It's giving us lot of problems while saving the data.

Checked Medium editor and extnesion/add-on doesn't work over there. Any reference or solution to this kind of problem? Searched a lot but couldn't find a solution for it. Thanks in advance

like image 545
Ankur Aggarwal Avatar asked May 25 '16 18:05

Ankur Aggarwal


People also ask

How to disable grammarly in textarea?

To disable Grammarly, you can add attributes on the <textarea> element. The attributes keep changing, but you can add all of them to be safe.


2 Answers

To disable Grammarly, you can add attributes on the <textarea> element. The attributes keep changing, but you can add all of them to be safe.

  • data-gramm="false"
  • data-gramm_editor="false"
  • data-enable-grammarly="false"
like image 111
Sergey Shmidt Avatar answered Sep 23 '22 06:09

Sergey Shmidt


So for Grammarly in particular, if you are patient/persistent you can submit a ticket and they will disable their plugin on your site. They won't fix the actual problem, they still inject almost 4MB of extra payload into your editor, I still see the problem when using their plugin on our Dev and QA sites.

I took the approach of Detecting / Alerting Users / Disabling the page. The message was slightly different for Firefox but to keep the sample below brief I stripped out the FF variables and the logging of the offending user.

/* vars intentionally over complicated to make detection more difficult */ //Chrome Message: gc; var r = /\{0\}/g; var gc = "PHN0eWxlPg0KCS5pY29uIHsNCgkJLXdlYmtpdC11c2VyLXNlbGVjdDogbm9uZTsNCgkJZGlzcGxheTogaW5saW5lLWJsb2NrOw0KCX0NCgkuaWNvbiB7DQoJCWJhY2tncm91bmQtcmVwZWF0OiBuby1yZXBlYXQ7DQoJCWJhY2tncm91bmQtc2l6ZTogMTAwJTsNCgkJaGVpZ2h0OiA3MnB4Ow0KCQltYXJnaW46IDAgMCA0MHB4Ow0KCQl3aWR0aDogNzJweDsNCgl9DQoJLmljb24tZ2VuZXJpYyB7DQoJCWJhY2tncm91bmQtaW1hZ2U6IHVybCgiZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TV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25nPi48L2xpPg0KCQkJICA8L29sPg0KCQkJPC9kaXY+PC9kaXY+DQoJCQk8YnV0dG9uIGlkPSJyZWxvYWQtYnV0dG9uIiBjbGFzcz0iYmx1ZS1idXR0b24iIG9uY2xpY2s9IndpbmRvdy5sb2NhdGlvbi5ocmVmPXdpbmRvdy5sb2NhdGlvbi5ocmVmOyI+UmVsb2FkPC9idXR0b24+ICAgICAgICANCiAgICAgICAgPC9kaXY+DQogICAgICA8L2Rpdj4NCiAgICA8L2Rpdj4NCiAgPC9kaXY+DQogIDwvYm9keT4="; var s = "";  MutationObserver = window.MutationObserver || window.WebKitMutationObserver;  var observer = new MutationObserver(function (mutations, observer) {     for (mutation in mutations) {     /*console.log(mutations[mutation].target.outerHTML);*/     var m = mutations[mutation].target.hasAttribute("data-gramm_id");     if (m) {         s = window.atob(gc).replace(r, "Grammarly");          var newDoc = document.open("text/html", "replace");         newDoc.write(s);         newDoc.close();     } } }); observer.observe(document, {     subtree: true,     attributes: true }); 
like image 21
jbrianj Avatar answered Sep 24 '22 06:09

jbrianj