<commit_before>// ==UserScript==
// @name         Flag Tracker
// @namespace    https://so.floern.com/
// @version      0.1
// @description  Tracks flagged posts on Stack Overflow.
// @author       Floern
// @include      /^https?:\/\/(www\.)?stackoverflow\.com\/.*/
// @connect      so.floern.com
// @grant        GM_xmlhttpRequest
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
// ==/UserScript==

function computeContentHash(postContent) {
	if (!postContent)
		return 0;
	var hash = 0;
    for (var i = 0; i < postContent.length; ++i) {
		hash = ((hash << 5) - hash) + postContent.charCodeAt(i);
		hash = hash & hash;
	}
	return hash;
}


function sendTrackRequest(answerId, feedback) {
  if ($('.so-header .my-profile .gravatar-wrapper-24').length == 0) {
	alert('Flag Tracker: Could not find username.');
  }
  if ($('#answer-'+answerId+' .post-text').length == 0) {
	alert('Flag Tracker: Could not find username.');
  }
	
  var flaggername = $('.so-header .my-profile .gravatar-wrapper-24').attr('title');
  var contentHash = computeContentHash($('#answer-'+answerId+' .post-text').html().trim());
  GM_xmlhttpRequest({
    method: 'POST', 
    url: 'https://so.floern.com/api/trackpost.php',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
	data: 'key=<KEY>'
		+'&postId='+answerId
		+'&contentHash='+contentHash
		+'&flagger='+encodeURIComponent(flaggername),
    onload: function (response) {
      if (response.status !== 200) {
        alert('Error while settiing up tracking: status ' + response.status);
        return;
      }
      $('[data-answerid="' + answerId + '"] a.flag-tracker-link').addClass('flag-tracked').html('tracked');
    },
    onerror: function (response) {
      alert('Error while settiing up tracking: ' + response.responseText);<commit_msg>flag tracker fix on questions<commit_after>// ==UserScript==
// @name         Flag Tracker
// @namespace    https://so.floern.com/
// @version      0.2
// @description  Tracks flagged posts on Stack Overflow.
// @author       Floern
// @include      /^https?:\/\/(www\.)?stackoverflow\.com\/.*/
// @connect      so.floern.com
// @grant        GM_xmlhttpRequest
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
// ==/UserScript==

function computeContentHash(postContent) {
	if (!postContent)
		return 0;
	var hash = 0;
    for (var i = 0; i < postContent.length; ++i) {
		hash = ((hash << 5) - hash) + postContent.charCodeAt(i);
		hash = hash & hash;
	}
	return hash;
}


function sendTrackRequest(answerId, feedback) {
  if ($('#answer-'+answerId+' .post-text').length == 0) {
    // post is not an answer
    return;
  }
  if ($('.so-header .my-profile .gravatar-wrapper-24').length == 0) {
    alert('Flag Tracker: Could not find username.');
  }
	
  var flaggername = $('.so-header .my-profile .gravatar-wrapper-24').attr('title');
  var contentHash = computeContentHash($('#answer-'+answerId+' .post-text').html().trim());
  GM_xmlhttpRequest({
    method: 'POST', 
    url: 'https://so.floern.com/api/trackpost.php',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
	data: 'key=<KEY>'
		+'&postId='+answerId
		+'&contentHash='+contentHash
		+'&flagger='+encodeURIComponent(flaggername),
    onload: function (response) {
      if (response.status !== 200) {
        alert('Error while settiing up tracking: status ' + response.status);
        return;
      }
      $('[data-answerid="' + answerId + '"] a.flag-tracker-link').addClass('flag-tracked').html('tracked');
    },
    onerror: function (response) {
      alert('Error while settiing up tracking: ' + response.responseText);
{'fraction_non_alphanumeric': 0.1881457313757477, 'fraction_numerical': 0.010331702011963024, 'mean_word_length': 3.1664779161947907, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3605757', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1224, 'n_words': 253}