Show confirmation after site labeling
This commit is contained in:
parent
ce74cda636
commit
6f77313363
@ -457,7 +457,11 @@ function saveLabel(response: ShinigamiEyesSubmission) {
|
||||
getPendingSubmissions().push(response);
|
||||
submitPendingRatings();
|
||||
//console.log(response);
|
||||
browser.tabs.sendMessage(response.tabId, { updateAllLabels: true });
|
||||
browser.tabs.sendMessage(response.tabId, <ShinigamiEyesCommand>{
|
||||
updateAllLabels: true,
|
||||
confirmSetIdentifier: response.identifier,
|
||||
confirmSetLabel: response.mark
|
||||
});
|
||||
//browser.tabs.executeScript(response.tabId, {code: 'updateAllLabels()'});
|
||||
return;
|
||||
}
|
||||
@ -501,7 +505,14 @@ browser.contextMenus.onClicked.addListener(function (info, tab) {
|
||||
// elementId: info.targetElementId,
|
||||
debug: <any>overrides.debug
|
||||
}, { frameId: frameId }, response => {
|
||||
if (!response.identifier) return;
|
||||
if (!response.identifier){
|
||||
browser.tabs.sendMessage(response.tabId, <ShinigamiEyesCommand>{
|
||||
updateAllLabels: true,
|
||||
confirmSetIdentifier: response.identifier,
|
||||
confirmSetLabel: response.mark
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (response.mark) {
|
||||
if (badIdentifiers[response.identifier]) return;
|
||||
if (response.secondaryIdentifier && badIdentifiers[response.secondaryIdentifier])
|
||||
|
@ -530,10 +530,26 @@ function getSnippet(node: HTMLElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function displayConfirmation(identifier: string, label: LabelKind){
|
||||
const confirmation = document.createElement('div');
|
||||
confirmation.style.cssText = 'position: fixed; padding: 15px; z-index: 99999999;';
|
||||
confirmation.textContent = identifier + (
|
||||
label == 't-friendly' ? ' will be displayed as trans-friendly' :
|
||||
label == 'transphobic' ? ' will be displayed as anti-trans' :
|
||||
' has been cleared.'
|
||||
) + ' on search engines and social networks.'
|
||||
document.body.appendChild(confirmation);
|
||||
setTimeout(() => {
|
||||
confirmation.remove();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener<ShinigamiEyesMessage, ShinigamiEyesSubmission>((message, sender, sendResponse) => {
|
||||
|
||||
if (message.updateAllLabels) {
|
||||
if(!isSocialNetwork && message.confirmSetLabel){
|
||||
displayConfirmation(message.confirmSetIdentifier, message.confirmSetLabel);
|
||||
}
|
||||
updateAllLabels(true);
|
||||
return;
|
||||
}
|
||||
@ -569,5 +585,6 @@ browser.runtime.onMessage.addListener<ShinigamiEyesMessage, ShinigamiEyesSubmiss
|
||||
if (message.debug <= 1)
|
||||
setTimeout(() => snippet.classList.remove(debugClass), 1500)
|
||||
}
|
||||
message.isSocialNetwork = isSocialNetwork;
|
||||
sendResponse(message);
|
||||
})
|
3
extension/definitions.d.ts
vendored
3
extension/definitions.d.ts
vendored
@ -24,6 +24,7 @@ interface ShinigamiEyesSubmission {
|
||||
contextPage?: string
|
||||
linkId?: number
|
||||
snippet?: string
|
||||
isSocialNetwork?: boolean
|
||||
}
|
||||
interface ShinigamiEyesCommand {
|
||||
acceptClicked?: boolean
|
||||
@ -32,6 +33,8 @@ interface ShinigamiEyesCommand {
|
||||
updateAllLabels?: boolean
|
||||
closeCallingTab?: boolean
|
||||
setTheme?: string
|
||||
confirmSetIdentifier?: string
|
||||
confirmSetLabel?: LabelKind
|
||||
}
|
||||
type LabelMap = { [identifier: string]: LabelKind };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user