Exemple #1
0
def results_nojs():
    yes = render_template('_yes.html')
    no = render_template('_no.html')
    partial = render_template('_partial.html')

    ad_result = tracker_result = dnt_result = no
    if get_count_from_str(string_default_blank(request.args.get('a'))) < 4:
        ad_result = yes
    if get_count_from_str(string_default_blank(request.args.get('t'))) < 4:
        tracker_result = yes
    # if for the last pageload (the fourth one, or try2) we block some 3rd
    # party trackers but not the dnt one, then we're using privacy badger
    if get_count_from_str(
            " ".join([
                string_default_blank(request.args.get('t')),
                string_default_blank(request.args.get('a')),
                string_default_blank(request.args.get('dnt'))
            ]), heuristic_filter) < 3:
        if get_count_from_str(string_default_blank(request.args.get('dnt')),
                              heuristic_filter) == 1:
            dnt_result = yes

    tool_recommendation = None
    detection = None
    if ad_result == yes and tracker_result == yes and dnt_result == yes:
        summary_sentence = render_template('_summary_sentence_yes.html')
    elif ad_result == yes and tracker_result == yes and dnt_result == no:
        summary_sentence = render_template('_summary_sentence_yes.html')
    else:
        if ad_result == no and tracker_result == no:
            summary_sentence = render_template('_summary_sentence_no.html')
        else:
            summary_sentence = render_template('_summary_sentence_mixed.html')
        detection = detect_browser_and_platform(
            request.headers.get('User-Agent'))

        tool_recommendation = get_tool_recommendation(detection)

        if detection['platform'] == "desktop" and (
                detection['browser'] == "chrome"
                or detection['browser'] == "firefox"):
            summary_sentence += " <strong>installing EFF's Privacy Badger</strong>"
        elif detection['platform'] == "desktop" and detection[
                'browser'] != "opera" and detection['browser'] != "ie":
            summary_sentence += " switching to a browser or OS that offers better protections."
        else:
            summary_sentence += " <strong>installing extra protections</strong>.  Privacy Badger isn't available for your browser / OS, but <a id='tool-recommendation' target='_blank' href='" + \
                tool_recommendation['url'] + "'>" + tool_recommendation['name'] + \
                "</a> may work for you."

    fingerprint_matching, fingerprint_content = fingerprint_generic(
        False, True)
    if fingerprint_matching <= 10:
        fingerprint_result = no
    elif fingerprint_matching <= 50:
        fingerprint_result = partial
    else:
        fingerprint_result = yes

    if ad_result != no and tracker_result != no:
        if fingerprint_result == partial:
            dnt_result = yes
        elif fingerprint_result == yes:
            ad_result = yes
            tracker_result = yes
            dnt_result = yes

    retest_link = "https://" + \
        config.third_party_trackers['ad_server'] + "/clear-all-cookies-nojs"

    return render_template('results_nojs.html',
                           summary_sentence=summary_sentence,
                           tool_recommendation=tool_recommendation,
                           detection=detection,
                           fingerprint_content=fingerprint_content,
                           ad_result=ad_result,
                           tracker_result=tracker_result,
                           dnt_result=dnt_result,
                           fingerprint_result=fingerprint_result,
                           no=no,
                           retest_link=retest_link)
Exemple #2
0
def results_nojs():
    yes = render_template('_yes.html')
    no = render_template('_no.html')
    partial = render_template('_partial.html')

    ad_result = tracker_result = dnt_result = no
    if get_count_from_str(request.args.get('a')) < 4:
        ad_result = yes
    if get_count_from_str(request.args.get('t')) < 4:
        tracker_result = yes
    # if for the last pageload (the fourth one, or try2) we block some 3rd
    # party trackers but not the dnt one, then we're using privacy badger
    if get_count_from_str(
            " ".join([
                request.args.get('t'),
                request.args.get('a'),
                request.args.get('dnt')
            ]), heuristic_filter) < 3:
        if get_count_from_str(request.args.get('dnt'), heuristic_filter) == 1:
            dnt_result = yes

    tool_recommendation = None
    detection = None
    if ad_result == yes and tracker_result == yes and dnt_result == yes:
        summary_sentence = render_template('_summary_sentence_yes.html')
    elif ad_result == yes and tracker_result == yes and dnt_result == no:
        summary_sentence = render_template(
            '_summary_sentence_yes_sans_dnt.html')
    else:
        if ad_result == no and tracker_result == no:
            summary_sentence = render_template('_summary_sentence_no.html')
        else:
            summary_sentence = render_template('_summary_sentence_mixed.html')
        detection = detect_browser_and_platform(
            request.headers.get('User-Agent'))

        tool_recommendation = get_tool_recommendation(detection)

        if detection['platform'] == "desktop" and (detection['browser'] == "chrome" or detection['browser'] == "firefox"):
            summary_sentence += " <strong>installing EFF's Privacy Badger</strong>"
        elif detection['platform'] == "desktop" and detection['browser'] != "opera" and detection['browser'] != "ie":
            summary_sentence += " switching to a browser or OS that offers better protections."
        else:
            summary_sentence += " <strong>installing extra protections</strong>.  Privacy Badger isn't available for your browser / OS, but <a id='tool-recommendation' target='_blank' href='" + \
                tool_recommendation['url'] + "'>" + tool_recommendation['name'] + \
                "</a> may work for you."

    fingerprint_matching, fingerprint_content = fingerprint_generic(
        False, True)
    if fingerprint_matching <= 20:
        fingerprint_result = no
    elif fingerprint_matching <= 100:
        fingerprint_result = partial
    else:
        fingerprint_result = yes

    retest_link = "https://" + \
        config.third_party_trackers['ad_server'] + "/clear-all-cookies-nojs"

    return render_template('results_nojs.html',
                           summary_sentence=summary_sentence,
                           tool_recommendation=tool_recommendation,
                           detection=detection,
                           fingerprint_content=fingerprint_content,
                           ad_result=ad_result,
                           tracker_result=tracker_result,
                           dnt_result=dnt_result,
                           fingerprint_result=fingerprint_result,
                           retest_link=retest_link)