diff --git a/build.sh b/build.sh index a9bee3f..d05445e 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,10 @@ -#!/bin/bash - -mkdir -p build; rm -rf build/* -mkdir -p dist; rm -rf dist/* -cp -r src build/firefox -cp -r src build/chrome -node mixin.js firefox/manifest.json build/firefox/manifest.json -cd build/chrome; zip -r ../../dist/chrome.zip *; cd ../.. -cd build/firefox; zip -r ../../dist/firefox.xpi *; cd ../.. +#!/bin/bash + +mkdir -p build; rm -rf build/* +mkdir -p dist; rm -rf dist/* +cp -r src build/firefox +cp -r src build/chrome +node mixin.js firefox/manifest.json build/firefox/manifest.json +cd build/chrome; zip -r ../../dist/chrome.zip *; cd ../.. +cd build/firefox; zip -r ../../dist/firefox.xpi *; cd ../.. rm -rf build \ No newline at end of file diff --git a/src/manifest.json b/src/manifest.json index 6ac1f69..7e7df09 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", - "version": "3.3.7", + "version": "3.4.0", "homepage_url": "https://tosdr.org", "background": { "scripts": [ diff --git a/src/popup/js/popup.js b/src/popup/js/popup.js index b555ddb..3854239 100644 --- a/src/popup/js/popup.js +++ b/src/popup/js/popup.js @@ -1,135 +1,153 @@ -/* global window, $, jQuery, getLiveServiceDetails, getRatingText, -getTweetText, browser, FALLBACK_SHIELDS, log */ -/* eslint-disable indent */ - -function escapeHTML(unsafe) { - return (`${unsafe}`) - .replace(/&(?!amp;)/g, '&') - .replace(/<(?!lt;)/g, '<') - .replace(/>(?!gt;)/g, '>') - .replace(/"(?!quot;)/g, '"') - .replace(/'(?!#039;)/g, '''); -} - -jQuery(() => { - function tosdrPoint(service, dataPoint) { - let badge; - let icon; - // let sign; - if (dataPoint) { - if (dataPoint.tosdr.point === 'good') { - badge = 'badge-success'; - icon = 'thumbs-up'; - // sign = '+'; - } else if (dataPoint.tosdr.point === 'bad') { - badge = 'badge-warning'; - icon = 'thumbs-down'; - // sign = '-'; - } else if (dataPoint.tosdr.point === 'blocker') { - badge = 'badge-important'; - icon = 'times'; - // sign = '×'; - } else if (dataPoint.tosdr.point === 'neutral') { - badge = 'badge-secondary'; - icon = 'asterisk'; - // sign = '→'; - } else { - badge = ''; - icon = 'question'; - // sign = '?'; - } - const pointText = dataPoint.description || ''; - - // Extract links from text - const taggedText = pointText.split(/(<\/?\w+(?:(?:\s+\w+(?:\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)/gim); - $(`#popup-point-${service.id}-${dataPoint.id}`) - .append($('
', { class: dataPoint.point }) - .append($('
') - .append($('', { class: `badge ${badge}`, title: escapeHTML(dataPoint.tosdr.point) }) - .append($('
  • ', { class: `fas fa-${icon}` }))) - .append($('', { - href: escapeHTML(dataPoint.discussion), target: '_blank', class: 'ml-2', text: dataPoint.title, - })))); - - $(`#popup-point-${service.id}-${dataPoint.id}`).append($('

    ')); - if (taggedText.length > 1) { - taggedText.forEach((t) => { - $(`#popup-point-${service.id}-${dataPoint.id} p`).append(t); - }); - } else { - $(`#popup-point-${service.id}-${dataPoint.id} p`).text(pointText); - } - } - } - const serviceUrl = window.location.hash.substr(1); - function updatePopup() { - $('.loading').show(); - getLiveServiceDetails(serviceUrl).then((service) => { - log('service', service); - browser.storage.local.get('settings').then((items) => { - $('#service_url').attr('href', `https://tosdr.org/en/service/${service.id}`); - $('#service_class').addClass(service.class); - if (service.class !== false) { - $('#service_class').text(`Grade ${service.class}`); - $('#ratingText').text(getRatingText(service.class)); - } else { - $('#service_class').text('No Grade Yet'); - $('#service_class').remove(); - $('#ratingText').text(getRatingText(service.class)); - } - - // Points - service.points.forEach((p) => { - $('.tosdr-points').append($('

  • ', { id: `popup-point-${service.id}-${p}`, class: 'point' })); - tosdrPoint(service, service.pointsData[p]); - }); - - // links inside of the dataPoints should open in a new window - $('.tosdr-points a').attr('target', '_blank'); - - if (!items.settings.hideshields) { - $('#shieldimg').attr('src', `${(typeof items.settings === 'undefined' ? FALLBACK_SHIELDS : items.settings.shield_endpoint)}/${service.id}.svg`); - $('#shieldurl').val(`${(typeof items.settings === 'undefined' ? FALLBACK_SHIELDS : items.settings.shield_endpoint)}${service.id}.svg`); - $('#privacyshield').show(); - } - if (items.settings.curator) { - $('#edit_url').attr('href', `https://edit.tosdr.org/services/${service.id}/edit`); - $('#add_document_url').attr('href', `https://edit.tosdr.org/documents/new?service=${service.id}`); - $('[data-visiblity="curator"]').show(); - } - $('#serviceimg').attr('src', service.image).addClass('float-right'); - if (getTweetText(service) !== false) { - $('#twitter_url').attr('href', encodeURI(`https://twitter.com/intent/tweet?text=${getTweetText(service)}&via=ToSDR&hashtags=ToS`)); - } else { - $('#twitter_url').remove(); - } - - if (Object.keys(service.links).length > 0) { - $('#linksList') - .append($('

    ', { text: 'Read the Terms' })) - .append($('