ACQUA: StackExchange best answer predictor

G. Gkotsis, K. Stepanyan, C. Pedrinaci, J. Domingue, and M. Liakata. It's all in the Content: State of the art Best Answer Prediction based on Discretisation of Shallow Linguistic Features. In Proceedings of the 2014 ACM Conference on Web Science, WebSci '14, pages 202-210, New York, NY, USA, 2014. ACM.

  1. // ==UserScript==
  2. // @name ACQUA: StackExchange best answer predictor
  3. // @namespace https://acqua.kmi.open.ac.uk/
  4. // @description G. Gkotsis, K. Stepanyan, C. Pedrinaci, J. Domingue, and M. Liakata. It's all in the Content: State of the art Best Answer Prediction based on Discretisation of Shallow Linguistic Features. In Proceedings of the 2014 ACM Conference on Web Science, WebSci '14, pages 202-210, New York, NY, USA, 2014. ACM.
  5. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  6. // @include http*://*.stackexchange.com/questions/*
  7. // @include http*://stackoverflow.com/questions/*
  8. // @include http*://askubuntu.com/questions/*
  9. // @include http*://mathoverflow.net/questions/*
  10. // @include http*://serverfault.com/questions/*
  11. // @include http*://superuser.com/questions/*
  12. // @version 1.3
  13. // @run-at document-end
  14. // @grant GM_xmlhttpRequest
  15. // ==/UserScript==
  16.  
  17. // GM_getResourceURL
  18.  
  19. URL = "https://acqua.kmi.open.ac.uk/predict?URL=" + document.URL;
  20.  
  21. GM_xmlhttpRequest({
  22. method: "GET",
  23. url: URL,
  24. onload: function(xhr) {
  25. id = "#answer-"+xhr.responseText;
  26. var num = parseInt(xhr.responseText) || 0;
  27. if (num==0){
  28. // $("#question").append( "<p></p><p class='question-hyperlink'><a href='https://acqua.kmi.open.ac.uk' target='new'>AcQUA: you need to authenticate!</a></p>" );
  29. $("#header").append("<div style='display:-moz-inline-stack;display:inline-block;background:url(https://acqua.kmi.open.ac.uk/page/img/acqua-icon-white.png) 5px 8px no-repeat #9a3334;margin:-15px 0;font-size:medium;padding:12px 10px 6px 34px;color:#fff;zoom:1;*display:inline;'>Acqua: You need to <a href='https://acqua.kmi.open.ac.uk/authenticate' style='color:#fff;border-bottom:1px solid #fff;' target=='_new' title='Authenticate'>authenticate</a></div>");
  30. }
  31. else
  32. $("#header").append("<div style='display:-moz-inline-stack;display:inline-block;background:url(https://acqua.kmi.open.ac.uk/page/img/acqua-icon-white.png) 5px 8px no-repeat #003366;margin:-15px 0;font-size:medium;padding:12px 10px 6px 34px;color:#fff;zoom:1;*display:inline;'>Acqua is loaded</div>");
  33.  
  34. $(id).prepend( "<div style='display:block;text-align:right;padding:20px 15px 0 0'><a href='https://acqua.kmi.open.ac.uk' title='ACQUA' target='_blank'><img src='https://acqua.kmi.open.ac.uk/page/img/acqua-icon.png' alt='ACQUA icon'></a></div>");
  35. // $(id+" :first").prepend( "<div style='display:block;text-align:right;padding:20px 15px 0 0'><a href='https://acqua.kmi.open.ac.uk' title='ACQUA' target='_blank'><img src='https://acqua.kmi.open.ac.uk/page/img/acqua-icon.png' alt='ACQUA icon'></a></div>");
  36.  
  37. $(id).css({"border-color": "#1b75bb",
  38. "border-width":"5px",
  39. "border-style":"solid"});
  40. // $(id).append("<span style='width: 45%;float: right' id='acquafeedback'>AcQUA: Did you find this useful? <a id='acquayes'>Yes</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id='acquano'>No</a></span>");
  41. $(id).append("<span style='background:url(https://acqua.kmi.open.ac.uk/page/img/acqua-icon-white.png) #1b75bb no-repeat 15px 0px;display:block;color:#fff;padding:5px 15px 5px 45px;float: right;' id='acquafeedback'>ACQUA: Did you find this useful? <a id='acquayes' style='background:#003366;margin-left:6px;padding:2px 2px;color:#fff'>Yes</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id='acquano' style='background:#003366;margin-left:6px;padding:2px 2px;color:#fff'>No</a></span>");
  42.  
  43. $('#acquayes').hover(function(){
  44. $(this).css('background','#9a3334');
  45. }, function(){$(this).css('background','#003366');}
  46. );
  47.  
  48. $('#acquano').hover(function(){
  49. $(this).css('background','#9a3334');
  50. }, function(){$(this).css('background','#003366');}
  51. );
  52.  
  53. $("#acquayes").click (function () {
  54. $.ajax({
  55. url: "https://acqua.kmi.open.ac.uk/feedback?answer=yes&id="+xhr.responseText,
  56. jsonp: "callback",
  57. dataType: "jsonp",
  58. data: {
  59. q: "",
  60. format: "json"
  61. },
  62. success: function( response ) {
  63. ;
  64. }, error:function(response){$('#acquafeedback').html("Thank you!");}
  65. });
  66.  
  67. });
  68.  
  69. $("#acquano").click (function () {
  70. $.ajax({
  71. url: "https://acqua.kmi.open.ac.uk/feedback?answer=no&id="+xhr.responseText,
  72. jsonp: "callback",
  73. dataType: "jsonp",
  74. data: {
  75. q: "",
  76. format: "json"
  77. },
  78. success: function( response ) {
  79. ;
  80. }, error:function(response){$('#acquafeedback').html("Thank you!");}
  81. });
  82. });
  83.  
  84.  
  85. }
  86. });