diff options
| author | hackademix <giorgio@maone.net> | 2018-09-18 23:43:28 +0200 | 
|---|---|---|
| committer | hackademix <giorgio@maone.net> | 2018-09-18 23:43:28 +0200 | 
| commit | 475a6b9e9ab5a47f8ea15c5b7e17f38d596b51a4 (patch) | |
| tree | 83e7cc6395cd6e1d3b94ba5cd23822963db8598d | |
| parent | 813daae97602ad7143e23fd6d955bef5e413dc7a (diff) | |
Initial refactoring and unhiding of contact finder / complaint UI.
| -rw-r--r-- | content/contactFinder.css | 56 | ||||
| -rw-r--r-- | content/contactFinder.js (renamed from contact_finder.js) | 0 | ||||
| -rw-r--r-- | html/display_panel/content/panel-styles.css | 6 | ||||
| -rw-r--r-- | html/preferences_panel/preferences_panel.html | 10 | ||||
| -rw-r--r-- | html/preferences_panel/prefs.css | 4 | ||||
| -rw-r--r-- | main_background.js | 38 | 
6 files changed, 89 insertions, 25 deletions
diff --git a/content/contactFinder.css b/content/contactFinder.css new file mode 100644 index 0000000..e9ce93e --- /dev/null +++ b/content/contactFinder.css @@ -0,0 +1,56 @@ +#_LibreJS_CF_panel { +  opacity: 0.8 !important; +  font-family: sans-serif !important; +  font-size: 1.2em !important; +  color: #000 !important; +  z-index: 2147483647 !important; +  background-color: #eee !important; +  position: fixed !important; +  display:inline-block !important; +  border: 2px solid #444 !important; +  text-align: center !important; +  width: 50% !important; +  top: 25% !important; +  bottom: 25% !important; +  left: 25% !important; +  right: 25% !important; +  transition: width .5s !important; +} +#_LibreJS_CF_panel:hover { +  opacity: 1 !important; +} +#_LibreJS_CF_panel h3, #LibreJS_CF_panel h4, #LibreJS_CF_panel h5 { +  font-family: sans-serif !important; +  color: #000 !important; +  background: transparent !important; +  font-weight: bold !important; +  text-align: center !important; +  border: none !important; +  padding: 0 !important; +  margin: .8em !important; +} + +#_libreJS_CF_panel a { +  text-decoration: none !important; +  color: #840 !important; +  border: none !important; +} + +#_libreJS_CF_panel a:hover { +  text-decoration: none !important; +  color: #c60 !important; +  border-bottom: 1px solid #840 !important; +} + + +#_LibreJS_CF_panel h3 { +  font-size: 2em !important; +} + +#_LibreJS_CF_panel h4 { +  font-size: 1.8em !important; +} + +#_LibreJS_CF_panel h5 { +  font-size: 1.5em !important; +} diff --git a/contact_finder.js b/content/contactFinder.js index 48f9c27..48f9c27 100644 --- a/contact_finder.js +++ b/content/contactFinder.js diff --git a/html/display_panel/content/panel-styles.css b/html/display_panel/content/panel-styles.css index cbf5cf5..0d849e4 100644 --- a/html/display_panel/content/panel-styles.css +++ b/html/display_panel/content/panel-styles.css @@ -149,9 +149,3 @@ span.blocked {    width: 100%;    text-align: center;  } - - - -#complain { -  display: none; /* TODO: Complaint to owner UI */ -} diff --git a/html/preferences_panel/preferences_panel.html b/html/preferences_panel/preferences_panel.html index effb724..70d3b86 100644 --- a/html/preferences_panel/preferences_panel.html +++ b/html/preferences_panel/preferences_panel.html @@ -71,15 +71,9 @@        <fieldset id="section-complaint"><legend>Complaint email defaults</legend>          <label for="pref_subject">Subject</label> -        <input id="pref_subject" type="text" -          value="Issues with Javascript on your website" -          /> +        <input id="pref_subject" type="text"/>          <label for="pref_body">Body</label> -        <textarea id="pref_body" rows="5" ->Please consider using a free license for the Javascript on your website. - -[Message generated by LibreJS. See https://www.gnu.org/software/librejs/ for more information] -</textarea> +        <textarea id="pref_body" rows="5"></textarea>        </fieldset>      </div>    </body> diff --git a/html/preferences_panel/prefs.css b/html/preferences_panel/prefs.css index b52d6c5..3ac498e 100644 --- a/html/preferences_panel/prefs.css +++ b/html/preferences_panel/prefs.css @@ -85,7 +85,3 @@ input[type="text"] {    background: #ffe;    color: #800;  } - -#section-complaint { -  display: none; /* TODO: Complaint to owner UI */ -} diff --git a/main_background.js b/main_background.js index 5b745c1..fdd895e 100644 --- a/main_background.js +++ b/main_background.js @@ -372,7 +372,7 @@ function connected(p) {  		// invoke_contact_finder  		if(m["invoke_contact_finder"] !== undefined){  			contact_finder = true; -			inject_contact_finder(); +			await injectContactFinder();  		}  		// a debug feature (maybe give the user an option to do this?)  		if(m["deletelocalstorage"] !== undefined){ @@ -1120,11 +1120,35 @@ var listManager = new ListManager(whitelist, blacklist,  			.map(script => script.hash)  	); + +async function initDefaults() { +	let defaults = { +		pref_subject: "Issues with Javascript on your website", +		pref_body: `Please consider using a free license for the Javascript on your website. + +[Message generated by LibreJS. See https://www.gnu.org/software/librejs/ for more information] +` +	}; +	let keys = Object.keys(defaults); +	let prefs = await browser.storage.local.get(keys); +	let changed = false; +	for (let k of keys) { +		if (!(k in prefs)) { +			prefs[k] = defaults[k]; +			changed = true; +		} +	} +	if (changed) { +		await browser.storage.local.set(prefs); +	} +} +  /**  *	Initializes various add-on functions  *	only meant to be called once when the script starts  */ -async function init_addon(){ +async function init_addon() { +	await initDefaults();  	await whitelist.load();  	browser.runtime.onConnect.addListener(connected);  	browser.storage.onChanged.addListener(options_listener); @@ -1154,11 +1178,11 @@ async function init_addon(){  /**  *	Loads the contact finder on the given tab ID.  */ -function inject_contact_finder(tab_id){ -	function executed(result) { -	  dbg_print("[TABID:"+tab_id+"]"+"finished executing contact finder: " + result); -	} -	var executing = browser.tabs.executeScript(tab_id, {file: "/contact_finder.js"}, executed); +async function injectContactFinder(tabId){ +	await Promise.all([ +		browser.tabs.executeScript(tabId, {file: "/content/contactFinder.js"}), +		browser.tabs.insertCSS(tabId, {file: "/content/contactFinder.css", cssOrigin: "user"}) +	]);  }  init_addon();  | 
