Make Diaspora work with LibreJS

With LibreJS installed visiting diaspora does not present the user with much, the stream is missing and all the items on the black bar are missing, it can be fixed by following this guide (I think) http://www.gnu.org/software/librejs/free-your-javascript.html
http://www.gnu.org/software/librejs/


Note: This discussion was imported from Loomio. Click here to view the original discussion.

Proposal: Should Diaspora be compatible with LibreJS plugin?

Currently when a user has LibreJS install much of the page on diaspora does not load, this can be fixed by following this guide: http://www.gnu.org/software/librejs/free-your-javascript.html


Outcome: N/A

Votes:

  • Yes: 18
  • Abstain: 2
  • No: 0
  • Block: 0

Note: This proposal was imported from Loomio. Vote details, some comments and metadata were not imported. Click here to view the proposal with all details on Loomio.

Shouldn’t this be discussed first? I have no idea what the pros and cons are, but the must be some.

Changed the close date by another month. Pros: causes issues for librejs users to go away, no reason the issue should be there AFAIK as all code is open. Cons: is it worth the effort? Are the number of users with the plugin negligible?

Not sure if this really needs to be voted on - if someone does the implementation then I’m sure no one would object?

In fact, there is a pull here but it hasn’t been finished yet :slight_smile:

Yep, no need to vote. Find a sane implementation that integrates well into rails asset pipeline and no one will object.

Anyone: feel free to continue here: https://github.com/diaspora/diaspora/pull/4838

Any news on this?

@nicolas8 seems support for LibreJS headers was merged in. No idea how it works myself, but if some parts of the JS are not LibreJS compliant, feel free to identify those and try to come up with a solution.

Thanks for the reply Jason! I’d love to help with code, but I’m not technically skilled in programming :frowning:

Anyways, LibreJS still blocks content on Diaspora:

List of blocked JavaScript in https://diasporabr.com.br/stream

This script is detected as inline, nonfree, defining functions or 

methods, and the rest of the page as loading external scripts
if(Array.isArray === undefined) {
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) == ‘[object
Array]’;
};
}
if ((window.history) && (window.history.pushState
=== undefined)) {
window.history.pushState = function() { };
}

NONTRIVIAL: creates script element dynamically.

//<![CDATA[
!window.jQuery && document.write(unescape('<script 

src="/assets/jquery-1db761a07a0a6fe3f80e026f788fef36.js"></script>’));

//]]>

This script is detected as inline, nonfree, defining functions or 

methods, and the rest of the page as loading external scripts

//<![CDATA[
jQuery.ajaxSetup({'cache': false});
//]]>

This script is detected as inline, nonfree, defining functions or 

methods, and the rest of the page as loading external scripts
Diaspora.I18n.load({“confirm_dialog”:“Tem
certeza?”,“confirm_unload”:“Por favor, confirme se deseja sair desta
página. Os dados que você informou não serão
salvos.”,“delete”:“Apagar”,“ignore”:“Ignorar”,“report”:{“prompt”:“Por
favor entre um motivo:”,“prompt_default”:“conteúdo
ofensivo”,“name”:“Relatar”,“status”:{“created”:“O relato foi criado com
sucesso”,“exists”:“O relato já existe”}},“ignore_user”:“Ignorar este
usuário?”,“ignore_failed”:“Não foi possível ignorar este
usuário”,“hide_post”:“esconder esta
publicação?”,“hide_post_failed”:“Incapaz de esconder esta
publicação”,“remove_post”:“Remover esta publicação?”,“unblock_failed”:“O
desbloqueio deste usuário
falhou”,“and”:“e”,“comma”:",",“edit”:“Editar”,“no_results”:“Nenhum
Resultado
Encontrado”,“timeago”:{“prefixAgo”:"",“prefixFromNow”:"",“suffixAgo”:“atrás”,“suffixFromNow”:"a

partir de agora",“seconds”:“menos de um minuto”,“minute”:“cerca de um
minuto”,“minutes”:"%d minutos",“hour”:“cerca de uma hora”,“hours”:"cerca
de %d ho…

This script is detected as inline, nonfree, defining functions or 

methods, and the rest of the page as loading external scripts

//<![CDATA[

window.gon={};gon.user={“id”:22077,“guid”:“54d640007fd5013287d0005056ba3b3d”,“name”:“xxxredactedxxx”,“diaspora_id”:“xxxredactedxxx”,“avatar”:{“small”:"https://diasporabr.com.br/uploads/images/xxxxredactedzzzz",“medium”:“https://diasporabr.com.br/uploads/images/thumb_medium_49186285e7800e40b8b8.jpg”,“large”:“https://diasporabr.com.br/uploads/images/thumb_large_49186285e7800e40b8b8.jpg”},“notifications_count”:10,“unread_messages_count”:0,“admin”:false,“aspects”:[{“id”:23225,“name”:“Amigos”,“selected”:true},{“id”:23232,“name”:“Serviços”,“selected”:true},{“id”:24395,“name”:"Não

conhecidos",“selected”:true},{“id”:23224,“name”:“Família”,“selected”:true},{“id”:23226,“name”:“Trabalho”,“selected”:true},{“id”:23227,“name”:“Conhecidos”,“selected”:true}],“services”:[],“following_count”:127,“configured_services”:[]};gon.preloads={};

//]]>

NONTRIVIAL: an open method similar to xhr.open is used

    var _paq = _paq || [];

    
    

    
    _paq.push(["trackPageView"]);
    _paq.push(["enableLinkTracking"]);

    (function() {
        var u=(("https:" == document.location.protocol) ? "https" : 

“http”) + “://pod1.diasporabr.com.br/”;
_paq.push([“setTrackerUrl”, u+“piwik.php”]);
_paq.push([“setSiteId”, “2”]);
var d=document, g=d.createElement(“script”),
s=d.getElementsByTagName(“script”)[0]; g.type=“text/javascript”;
g.defer=true; g.async=true; g.src=u+“piwik.js”;
s.parentNode.insertBefore(g,s);
})();

This script is detected as inline, nonfree, defining functions or 

methods, and the rest of the page as loading external scripts
[{“attribute”:“onclick”,“value”:"$.facebox.close();"}]

    NONTRIVIAL: square bracket suffix method call detected

[{“attribute”:“href”,“value”:"(function(){f=‘https://diasporabr.com.br/bookmarklet?url=’+encodeURIComponent(window.location.href)+’&title=’+encodeURIComponent(document.title)+’&notes=’+encodeURIComponent(’’+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+’&v=1&’;a=function(){if(!window.open(f+‘noui=1&jump=doclose’,‘diasporav1’,‘location=yes,links=no,scrollbars=yes,toolbar=no,width=620,height=400’))location.href=f+'jump=yes’};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"}]

NONTRIVIAL: eval has been found in code

https://diasporabr.com.br/assets/jquery_ujs-5be99745d2e19d4e06fd99998b1cb99b.js

error parsing: 7c99c132628414dd0a847377e8ce1940b3735744

https://diasporabr.com.br/assets/main-095e253fdb3755aa4844c4bb42e82ba0.js

NONTRIVIAL: an open method similar to xhr.open is used

https://diasporabr.com.br/assets/jsxc-e660beffa5fa259ea8f528e10ad756d7.js

This script is detected as nonfree, external, and as defining 

functions or methods

https://diasporabr.com.br/assets/templates-994dd5d1b8d11efc0df6804f529633ee.js

You could raise specific issues on Github regarding individual JS parts.

Maybe something like “Fix JS to comply with LibreJS” and list individual items as tasks in that issue, using the github tasks syntax.

I realize you opened an issue already but general issues like “fix all the things” don’t help developers to track what needs closing. An issue needs to have a clear goal, so a clear list of JS that needs to be refactored would help developers attack those parts of the code. By coordinating this work via an issue you can help without coding :slight_smile:

Thanks! Will do :slight_smile: