New Feature - Report URLs
Lately, I have received relatively few requests with potentially bad URLs. On the one hand, that could be because ClearURLs are working very well by now. But I also think that not everyone wants to sign up to GitLab to report a URL. That's why I've added a new button that reports the current URL in the active tab to me, so I can take a closer look at the URL. So that you can see exactly what data will be sent to me, I have uploaded the source code for the PHP script, of course, without a password etc. Please be careful not to send URLs with personal information or tokens.
This commit is contained in:
		
							parent
							
								
									dd3bbac0ba
								
							
						
					
					
						commit
						64ed933361
					
				| 
						 | 
					@ -154,6 +154,16 @@
 | 
				
			||||||
        "description": ""
 | 
					        "description": ""
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "popup_html_report_button": {
 | 
				
			||||||
 | 
					        "message": "Aktuelle URL melden",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "popup_html_report_button_title": {
 | 
				
			||||||
 | 
					        "message": "Meldet die aktuelle URL aus diesem Tab.",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    "core_save_on_disk": {
 | 
					    "core_save_on_disk": {
 | 
				
			||||||
        "message": "[ClearURLs]: Auf Festplatte gespeichert.",
 | 
					        "message": "[ClearURLs]: Auf Festplatte gespeichert.",
 | 
				
			||||||
        "description": ""
 | 
					        "description": ""
 | 
				
			||||||
| 
						 | 
					@ -217,5 +227,20 @@
 | 
				
			||||||
    "setting_types_label": {
 | 
					    "setting_types_label": {
 | 
				
			||||||
        "message": "<a href='https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType' target='_blank'>Request types</a> (Expertenniveau)",
 | 
					        "message": "<a href='https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType' target='_blank'>Request types</a> (Expertenniveau)",
 | 
				
			||||||
        "description": ""
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "setting_report_server_label": {
 | 
				
			||||||
 | 
					        "message": "Meldungsserver für URLs",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "success_report_url": {
 | 
				
			||||||
 | 
					        "message": "Die URL wurde erfolgreich gemeldet. Wir werden sie in Kürze prüfen.",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "error_report_url": {
 | 
				
			||||||
 | 
					        "message": "Es schaut so aus, als ob diese URL schon gemeldet wurde.",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -154,6 +154,16 @@
 | 
				
			||||||
        "description": ""
 | 
					        "description": ""
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "popup_html_report_button": {
 | 
				
			||||||
 | 
					        "message": "Report current URL",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "popup_html_report_button_title": {
 | 
				
			||||||
 | 
					        "message": "Report the current URL from this tab.",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    "core_save_on_disk": {
 | 
					    "core_save_on_disk": {
 | 
				
			||||||
        "message": "[ClearURLs]: Save on disk.",
 | 
					        "message": "[ClearURLs]: Save on disk.",
 | 
				
			||||||
        "description": ""
 | 
					        "description": ""
 | 
				
			||||||
| 
						 | 
					@ -217,5 +227,20 @@
 | 
				
			||||||
    "setting_types_label": {
 | 
					    "setting_types_label": {
 | 
				
			||||||
        "message": "<a href='https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType' target='_blank'>Request types</a> (expert level)",
 | 
					        "message": "<a href='https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType' target='_blank'>Request types</a> (expert level)",
 | 
				
			||||||
        "description": ""
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "setting_report_server_label": {
 | 
				
			||||||
 | 
					        "message": "Report server for URLs",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "success_report_url": {
 | 
				
			||||||
 | 
					        "message": "The URL was successfully reported. We will check this URL soon.",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "error_report_url": {
 | 
				
			||||||
 | 
					        "message": "It seems like this URL has already been reported.",
 | 
				
			||||||
 | 
					        "description": ""
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								clearurls.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								clearurls.js
									
									
									
									
									
								
							| 
						 | 
					@ -11,6 +11,7 @@ var siteBlockedAlert = 'javascript:void(0)';
 | 
				
			||||||
var dataHash;
 | 
					var dataHash;
 | 
				
			||||||
var localDataHash;
 | 
					var localDataHash;
 | 
				
			||||||
var os;
 | 
					var os;
 | 
				
			||||||
 | 
					var currentURL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var storage = [];
 | 
					var storage = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -580,6 +581,7 @@ function start(items)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                delete badges[tabId];
 | 
					                delete badges[tabId];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            currentURL = tabInfo.url;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
| 
						 | 
					@ -592,6 +594,9 @@ function start(items)
 | 
				
			||||||
        */
 | 
					        */
 | 
				
			||||||
        function handleActivated(activeInfo) {
 | 
					        function handleActivated(activeInfo) {
 | 
				
			||||||
            tabid = activeInfo.tabId;
 | 
					            tabid = activeInfo.tabId;
 | 
				
			||||||
 | 
					            browser.tabs.get(tabid).then(function (tab) {
 | 
				
			||||||
 | 
					                currentURL = tab.url;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
| 
						 | 
					@ -840,6 +845,7 @@ function initSettings()
 | 
				
			||||||
    storage.hashURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/rules.hash";
 | 
					    storage.hashURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/rules.hash";
 | 
				
			||||||
    storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.json";
 | 
					    storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.json";
 | 
				
			||||||
    storage.types = ["main_frame", "sub_frame", "xmlhttprequest"];
 | 
					    storage.types = ["main_frame", "sub_frame", "xmlhttprequest"];
 | 
				
			||||||
 | 
					    storage.reportServer = "https://clearurls.xn--rb-fka.it";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -875,3 +881,12 @@ function isEmpty(obj)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return (Object.getOwnPropertyNames(obj).length === 0);
 | 
					    return (Object.getOwnPropertyNames(obj).length === 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Returns the current URL.
 | 
				
			||||||
 | 
					 * @return {String} [description]
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function getCurrentURL()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return currentURL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,8 @@ var badgedStatus;
 | 
				
			||||||
var hashStatus;
 | 
					var hashStatus;
 | 
				
			||||||
var loggingStatus;
 | 
					var loggingStatus;
 | 
				
			||||||
var statisticsStatus;
 | 
					var statisticsStatus;
 | 
				
			||||||
 | 
					var currentURL;
 | 
				
			||||||
 | 
					var reportServer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var core = function (func) {
 | 
					var core = function (func) {
 | 
				
			||||||
    return browser.runtime.getBackgroundPage().then(func);
 | 
					    return browser.runtime.getBackgroundPage().then(func);
 | 
				
			||||||
| 
						 | 
					@ -26,6 +28,8 @@ function getData()
 | 
				
			||||||
        hashStatus = ref.getData('hashStatus');
 | 
					        hashStatus = ref.getData('hashStatus');
 | 
				
			||||||
        loggingStatus = ref.getData('loggingStatus');
 | 
					        loggingStatus = ref.getData('loggingStatus');
 | 
				
			||||||
        statisticsStatus = ref.getData('statisticsStatus');
 | 
					        statisticsStatus = ref.getData('statisticsStatus');
 | 
				
			||||||
 | 
					        currentURL = ref.getCurrentURL();
 | 
				
			||||||
 | 
					        reportServer = ref.getData('reportServer');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -174,6 +178,7 @@ $(document).ready(function(){
 | 
				
			||||||
        changeSwitchButton("statistics", "statisticsStatus");
 | 
					        changeSwitchButton("statistics", "statisticsStatus");
 | 
				
			||||||
        $('#loggingPage').attr('href', browser.extension.getURL('./html/log.html'));
 | 
					        $('#loggingPage').attr('href', browser.extension.getURL('./html/log.html'));
 | 
				
			||||||
        $('#settings').attr('href', browser.extension.getURL('./html/settings.html'));
 | 
					        $('#settings').attr('href', browser.extension.getURL('./html/settings.html'));
 | 
				
			||||||
 | 
					        $('#reportButton').on("click", reportURL);
 | 
				
			||||||
        setText();
 | 
					        setText();
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $('#config_section').remove();
 | 
					        $('#config_section').remove();
 | 
				
			||||||
| 
						 | 
					@ -202,6 +207,7 @@ function setText()
 | 
				
			||||||
    injectText('configs_switch_filter','popup_html_configs_switch_filter');
 | 
					    injectText('configs_switch_filter','popup_html_configs_switch_filter');
 | 
				
			||||||
    injectText('configs_head','popup_html_configs_head');
 | 
					    injectText('configs_head','popup_html_configs_head');
 | 
				
			||||||
    injectText('configs_switch_statistics','configs_switch_statistics');
 | 
					    injectText('configs_switch_statistics','configs_switch_statistics');
 | 
				
			||||||
 | 
					    injectText('reportButton', 'popup_html_report_button', true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -237,3 +243,19 @@ function translate(string)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return browser.i18n.getMessage(string);
 | 
					    return browser.i18n.getMessage(string);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Send the url to the DB on clearurls.röb.it to checked for tracking fields.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function reportURL()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    $.ajax({
 | 
				
			||||||
 | 
					        url: reportServer+'/report_url.php?url='+encodeURI(currentURL),
 | 
				
			||||||
 | 
					        success: function(result) {
 | 
				
			||||||
 | 
					            window.alert(translate('success_report_url'));
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        error: function(result) {
 | 
				
			||||||
 | 
					            window.alert(translate('error_report_url'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,7 @@ function save()
 | 
				
			||||||
        ref.setData('ruleURL', $('input[name=rule_url]').val());
 | 
					        ref.setData('ruleURL', $('input[name=rule_url]').val());
 | 
				
			||||||
        ref.setData('hashURL', $('input[name=hash_url]').val());
 | 
					        ref.setData('hashURL', $('input[name=hash_url]').val());
 | 
				
			||||||
        ref.setData('types', $('input[name=types]').val());
 | 
					        ref.setData('types', $('input[name=types]').val());
 | 
				
			||||||
 | 
					        ref.setData('reportServer', $('input[name=report_server]').val());
 | 
				
			||||||
        ref.saveOnExit();
 | 
					        ref.saveOnExit();
 | 
				
			||||||
        ref.reload();
 | 
					        ref.reload();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
| 
						 | 
					@ -76,6 +77,7 @@ function getData()
 | 
				
			||||||
        settings.rule_url = ref.getData('ruleURL');
 | 
					        settings.rule_url = ref.getData('ruleURL');
 | 
				
			||||||
        settings.hash_url = ref.getData('hashURL');
 | 
					        settings.hash_url = ref.getData('hashURL');
 | 
				
			||||||
        settings.types = ref.getData('types');
 | 
					        settings.types = ref.getData('types');
 | 
				
			||||||
 | 
					        settings.reportServer = ref.getData('reportServer');
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,4 +100,6 @@ function setText()
 | 
				
			||||||
    $('input[name=types]').val(settings.types);
 | 
					    $('input[name=types]').val(settings.types);
 | 
				
			||||||
    $('#save_settings_btn').text(translate('settings_html_save_button'));
 | 
					    $('#save_settings_btn').text(translate('settings_html_save_button'));
 | 
				
			||||||
    $('#save_settings_btn').prop('title', translate('settings_html_save_button_title'));
 | 
					    $('#save_settings_btn').prop('title', translate('settings_html_save_button_title'));
 | 
				
			||||||
 | 
					    $('#report_server_label').html(translate('setting_report_server_label'));
 | 
				
			||||||
 | 
					    $('input[name=report_server]').val(settings.reportServer);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,12 +133,19 @@
 | 
				
			||||||
        <div class="col-sm-1">
 | 
					        <div class="col-sm-1">
 | 
				
			||||||
            <div class="text-center">
 | 
					            <div class="text-center">
 | 
				
			||||||
                <a type="button" id="loggingPage" target="_blank"
 | 
					                <a type="button" id="loggingPage" target="_blank"
 | 
				
			||||||
                class="btn btn-default btn-sm btn-block">
 | 
					                class="btn btn-default btn-sm btn-block"></a>
 | 
				
			||||||
            </a>
 | 
					            </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</div>
 | 
					    <br />
 | 
				
			||||||
<br />
 | 
					    <div class="row" id="report_section">
 | 
				
			||||||
 | 
					        <div class="col-sm-1">
 | 
				
			||||||
 | 
					            <div class="text-center">
 | 
				
			||||||
 | 
					                <a type="button" id="reportButton" target="_blank"
 | 
				
			||||||
 | 
					                class="btn btn-warning btn-sm btn-block"></a>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <br />
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,11 @@
 | 
				
			||||||
                <input type="text" id="types" value="" name="types" class="form-control" />
 | 
					                <input type="text" id="types" value="" name="types" class="form-control" />
 | 
				
			||||||
            </p>
 | 
					            </p>
 | 
				
			||||||
            <br />
 | 
					            <br />
 | 
				
			||||||
 | 
					            <p>
 | 
				
			||||||
 | 
					                <label id="report_server_label"></label><br />
 | 
				
			||||||
 | 
					                <input type="text" id="report_server" value="" name="report_server" class="form-control" />
 | 
				
			||||||
 | 
					            </p>
 | 
				
			||||||
 | 
					            <br />
 | 
				
			||||||
            <p class="text-center">
 | 
					            <p class="text-center">
 | 
				
			||||||
                <button type="button" id="save_settings_btn"
 | 
					                <button type="button" id="save_settings_btn"
 | 
				
			||||||
                class="btn btn-success" title="Save the settings"></button>
 | 
					                class="btn btn-success" title="Save the settings"></button>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "manifest_version": 2,
 | 
					    "manifest_version": 2,
 | 
				
			||||||
    "name": "ClearURLs",
 | 
					    "name": "ClearURLs",
 | 
				
			||||||
    "version": "1.3.3.11",
 | 
					    "version": "1.3.3.12",
 | 
				
			||||||
    "author": "Kevin R.",
 | 
					    "author": "Kevin R.",
 | 
				
			||||||
    "description": "Remove tracking elements form URLs.",
 | 
					    "description": "Remove tracking elements form URLs.",
 | 
				
			||||||
    "homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
 | 
					    "homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										35
									
								
								server/report_url.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								server/report_url.php
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,35 @@
 | 
				
			||||||
 | 
					<?php
 | 
				
			||||||
 | 
					$servername = "...";
 | 
				
			||||||
 | 
					$username = "...";
 | 
				
			||||||
 | 
					$password = "...";
 | 
				
			||||||
 | 
					$dbname = "...";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(isset($_GET['url'])) $url = urldecode($_GET['url']);
 | 
				
			||||||
 | 
					else http_response_code(404);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if(!empty($url) && filter_var($url, FILTER_VALIDATE_URL))
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    $hash = md5($url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Create connection
 | 
				
			||||||
 | 
					    $conn = new mysqli($servername, $username, $password, $dbname);
 | 
				
			||||||
 | 
					    // Check connection
 | 
				
			||||||
 | 
					    if ($conn->connect_error) {
 | 
				
			||||||
 | 
					        http_response_code(505);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $sql = "INSERT INTO reports (hash, url) VALUES ('$hash', '$url')";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ($conn->query($sql) === TRUE) {
 | 
				
			||||||
 | 
					        http_response_code(200);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        http_response_code(500);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $conn->close();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					else {
 | 
				
			||||||
 | 
					    http_response_code(505);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					?>
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user