Changing layout some, implementing Primary theme

This commit is contained in:
Jean Viscogliosi-Pate 2025-01-24 00:43:02 -08:00
parent dec8ea8c74
commit 585cca6aa3
13 changed files with 1258 additions and 731 deletions

View File

@ -4,7 +4,7 @@ import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'src/replace-words.js',
output: {
file: 'src/replace-words-and-verbs.js',
file: 'src/content-script.js',
format: 'cjs',
},
plugins: [nodeResolve(), commonjs()]

680
src/content-script.js Normal file
View File

@ -0,0 +1,680 @@
'use strict';
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var replaceWords$1 = {};
var dist = {};
var hasRequiredDist;
function requireDist () {
if (hasRequiredDist) return dist;
hasRequiredDist = 1;
/**
* @license
* Copyright 2019 Ludan Stoecklé
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(dist, "__esModule", { value: true });
dist.getConjugation = dist.getVerbInfo = dist.getIngPart = dist.mergeVerbsData = void 0;
const tenses = [
// SIMPLE
'SIMPLE_PAST',
'PAST',
'SIMPLE_PRESENT',
'PRESENT',
'SIMPLE_FUTURE',
'FUTURE',
// PROGRESSIVE
'PROGRESSIVE_PAST',
'PROGRESSIVE_PRESENT',
'PROGRESSIVE_FUTURE',
// PERFECT
'PERFECT_PAST',
'PERFECT_PRESENT',
'PERFECT_FUTURE',
// PERFECT PROGRESSIVE
'PERFECT_PROGRESSIVE_PAST',
'PERFECT_PROGRESSIVE_PRESENT',
'PERFECT_PROGRESSIVE_FUTURE',
// PARTICIPLE
'PARTICIPLE_PRESENT',
'PARTICIPLE_PAST',
];
const modals = ['can', 'could', 'may', 'might', 'must', 'shall', 'should', 'will', 'would', 'ought'];
// helpers
function mergeVerbsData(irregularsInfo, gerundsInfo) {
const res = {};
// gerunds
if (gerundsInfo) {
const gerundKeys = Object.keys(gerundsInfo);
for (const gerundKey of gerundKeys) {
const gerundVal = gerundsInfo[gerundKey];
res[gerundKey] = [null, null, gerundVal];
}
}
// irregulars
if (irregularsInfo) {
const irregularKeys = Object.keys(irregularsInfo);
for (const irregularKey of irregularKeys) {
const irregularVal = irregularsInfo[irregularKey];
if (!res[irregularKey]) {
res[irregularKey] = [irregularVal[0][0], irregularVal[0][1], null];
}
else {
res[irregularKey] = [irregularVal[0][0], irregularVal[0][1], res[irregularKey][2]];
}
}
}
return res;
}
dist.mergeVerbsData = mergeVerbsData;
function getIrregularHelper(verbsInfo, verb, index) {
const verbInfo = getVerbInfo(verbsInfo, verb);
if (verbInfo && verbInfo.length != 0) {
return verbInfo[index];
}
else {
return null;
}
}
function getCommonEdPart(verb) {
if (verb.endsWith('ie') || verb.endsWith('ee')) {
return verb + 'd';
}
else if (yWithVowel(verb)) {
// vowel + y: play -> played
return verb + 'ed';
}
else if (verb.endsWith('y')) {
// no vowel + y: cry -> cried
return verb.substring(0, verb.length - 1) + 'ied';
}
else if (verb.endsWith('e')) {
return verb + 'd';
}
else {
return verb + 'ed';
}
}
function getPastPart(verbsInfo, verb) {
if (verb === 'be') {
return 'been';
}
else {
const irregular = getIrregularHelper(verbsInfo, verb, 1);
if (irregular) {
return irregular;
}
else {
return getCommonEdPart(verb);
}
}
}
function getPreteritPart(verbsInfo, verb, person) {
let irregular;
if (verb === 'be') {
if (person === 0 || person === 2) {
return 'was';
}
else {
return 'were';
}
}
else if ((irregular = getIrregularHelper(verbsInfo, verb, 0))) {
return irregular;
}
else {
return getCommonEdPart(verb);
}
}
function getIngPart(verbsInfo, verb) {
const consonants = 'bcdfghjklmnpqrstvxzw';
const irregular = getIrregularHelper(verbsInfo, verb, 2);
if (irregular) {
return irregular;
}
else if (verb.match(new RegExp(`[${consonants}]e$`, 'g')) && verb != 'be' && verb != 'singe') {
// If the infinitive ends with a consonant followed by an e,
// you have to take off the e to form your present participle.
// this is not in the english-verbs-gerunds list
// hum and unless it is 'to be'! which becomes being, not bing.
return verb.substring(0, verb.length - 1) + 'ing';
}
else {
return verb + 'ing';
}
}
dist.getIngPart = getIngPart;
/* does not throw an exception:
most verb conjugation is rule based, thus not finding it in the resource is not a problem */
function getVerbInfo(verbsInfo, verb) {
return verbsInfo ? verbsInfo[verb] : null;
}
dist.getVerbInfo = getVerbInfo;
// 1 per tense
function getSimplePast(verbsInfo, verb, person) {
return getPreteritPart(verbsInfo, verb, person);
}
function yWithVowel(verb) {
return verb.match(/[aeiouy]y$/) !== null;
}
function getSimplePresentHeShe(verb) {
if (modals.indexOf(verb) > -1) {
return verb;
}
else if (verb === 'have') {
return 'has';
}
else if (verb === 'be') {
return 'is';
}
else if (verb === 'do') {
return 'does';
}
else if (verb === 'go') {
return 'goes';
}
else if (yWithVowel(verb)) {
// vowel + y: play -> plays
return verb + 's';
}
else if (verb.endsWith('y')) {
// no vowel + y: fly -> flies
return verb.substring(0, verb.length - 1) + 'ies';
}
else if (verb.endsWith('ss') || verb.endsWith('x') || verb.endsWith('sh') || verb.endsWith('ch')) {
return verb + 'es';
}
else {
// default
return verb + 's';
}
}
function getSimplePresent(verb, person) {
if (person != 2) {
if (verb === 'be') {
if (person === 0) {
return 'am';
}
else {
return 'are';
}
}
else {
return verb;
}
}
else {
return getSimplePresentHeShe(verb);
}
}
function getSimpleFuture(verb, person, isGoingTo, negative) {
if (isGoingTo) {
return getSimplePresent('be', person) + ' ' + getNegative(negative) + 'going to ' + verb;
}
else {
return 'will ' + getNegative(negative) + verb;
}
}
function getNegative(negative) {
return negative ? 'not ' : '';
}
function getProgressivePast(verbsInfo, verb, person, negative) {
return getPreteritPart(verbsInfo, 'be', person) + ' ' + getNegative(negative) + getIngPart(verbsInfo, verb);
}
function getProgressivePresent(verbsInfo, verb, person, negative) {
return getSimplePresent('be', person) + ' ' + getNegative(negative) + getIngPart(verbsInfo, verb);
}
function getProgressiveFuture(verbsInfo, verb, negative) {
return 'will ' + getNegative(negative) + 'be ' + getIngPart(verbsInfo, verb);
}
function getPerfectPast(verbsInfo, verb, negative) {
return 'had ' + getNegative(negative) + getPastPart(verbsInfo, verb);
}
function getPerfectPresent(verbsInfo, verb, person, negative) {
return getSimplePresent('have', person) + ' ' + getNegative(negative) + getPastPart(verbsInfo, verb);
}
function getPerfectFuture(verbsInfo, verb, negative) {
return 'will ' + getNegative(negative) + 'have ' + getPastPart(verbsInfo, verb);
}
function getPerfectProgressivePast(verbsInfo, verb, negative) {
return 'had ' + getNegative(negative) + 'been ' + getIngPart(verbsInfo, verb);
}
function getPerfectProgressivePresent(verbsInfo, verb, person, negative) {
return getSimplePresent('have', person) + ' ' + getNegative(negative) + 'been ' + getIngPart(verbsInfo, verb);
}
function getPerfectProgressiveFuture(verbsInfo, verb, negative) {
return 'will ' + getNegative(negative) + 'have been ' + getIngPart(verbsInfo, verb);
}
function doContract(original) {
const contractions = [
// present
['does not', "doesn't"],
['do not', "don't"],
['is not', "isn't"],
['are not', "aren't"],
['has not', "hasn't"],
['have not', "haven't"],
['can not', "can't"],
['could not', "couldn't"],
['may not', "mayn't"],
['might not', "mightn't"],
['will not', "won't"],
['shall not', "shan't"],
['would not', "wouldn't"],
['should not', "shouldn't"],
['must not', "mustn't"],
['ought not', "oughtn't"],
// past
['did not', "didn't"],
['was not', "wasn't"],
['were not', "weren't"],
['had not', "hadn't"],
];
for (const contraction of contractions) {
const replaced = original.replace(contraction[0], contraction[1]);
if (replaced !== original) {
// finding one in fine, then we stop
return replaced;
}
}
// istanbul ignore next
return original;
}
function getConjugatedVerb(verbsInfo, verb, tense, person, isNegative, isHaveNoDo, isGoingTo) {
switch (tense) {
case 'PAST':
case 'SIMPLE_PAST':
if (isNegative) {
if (verb === 'be' || verb === 'do' || modals.indexOf(verb) > -1 || isHaveNoDo) {
return getSimplePast(verbsInfo, verb, person) + ' not';
}
else {
// 'do ...' form
return getSimplePast(verbsInfo, 'do', person) + ' not ' + verb;
}
}
else {
return getSimplePast(verbsInfo, verb, person);
}
case 'PRESENT':
case 'SIMPLE_PRESENT':
if (isNegative) {
if (verb === 'be' || verb === 'do' || modals.indexOf(verb) > -1 || isHaveNoDo) {
return getSimplePresent(verb, person) + ' not';
}
else {
// 'do ...' form
return getSimplePresent('do', person) + ' not ' + verb;
}
}
else {
return getSimplePresent(verb, person);
}
case 'FUTURE':
case 'SIMPLE_FUTURE':
return getSimpleFuture(verb, person, isGoingTo, isNegative);
case 'PROGRESSIVE_PAST':
return getProgressivePast(verbsInfo, verb, person, isNegative);
case 'PROGRESSIVE_PRESENT':
return getProgressivePresent(verbsInfo, verb, person, isNegative);
case 'PROGRESSIVE_FUTURE':
return getProgressiveFuture(verbsInfo, verb, isNegative);
case 'PERFECT_PAST':
return getPerfectPast(verbsInfo, verb, isNegative);
case 'PERFECT_PRESENT':
return getPerfectPresent(verbsInfo, verb, person, isNegative);
case 'PERFECT_FUTURE':
return getPerfectFuture(verbsInfo, verb, isNegative);
case 'PERFECT_PROGRESSIVE_PAST':
return getPerfectProgressivePast(verbsInfo, verb, isNegative);
case 'PERFECT_PROGRESSIVE_PRESENT':
return getPerfectProgressivePresent(verbsInfo, verb, person, isNegative);
case 'PERFECT_PROGRESSIVE_FUTURE':
return getPerfectProgressiveFuture(verbsInfo, verb, isNegative);
case 'PARTICIPLE_PRESENT':
return (isNegative ? 'not ' : '') + getIngPart(verbsInfo, verb);
case 'PARTICIPLE_PAST':
return (isNegative ? 'not ' : '') + getPastPart(verbsInfo, verb);
}
}
function getConjugation(verbsInfo, verb, tense, person, extraParams) {
if (!verb) {
const err = new Error();
err.name = 'TypeError';
err.message = 'verb must not be null';
throw err;
}
if (tenses.indexOf(tense) == -1) {
const err = new Error();
err.name = 'TypeError';
err.message = `invalid tense: ${tense}`;
throw err;
}
if ([0, 1, 2, 3, 4, 5].indexOf(person) === -1) {
const err = new Error();
err.name = 'TypeError';
err.message = 'person must be 0 1 2 3 4 or 5';
throw err;
}
const isGoingTo = extraParams && extraParams.GOING_TO ? true : false;
const isNegative = extraParams && extraParams.NEGATIVE ? true : false;
const isHaveNoDo = isNegative && verb === 'have' && extraParams.NO_DO ? true : false;
const conjugated = getConjugatedVerb(verbsInfo, verb, tense, person, isNegative, isHaveNoDo, isGoingTo);
if (isNegative && (extraParams.CONTRACT || isHaveNoDo)) {
// Note that in the form without the auxiliary verb DO, the verb HAVE is always contracted with the adverb not.
return doContract(conjugated);
}
else {
return conjugated;
}
}
dist.getConjugation = getConjugation;
return dist;
}
var hasRequiredReplaceWords;
function requireReplaceWords () {
if (hasRequiredReplaceWords) return replaceWords$1;
hasRequiredReplaceWords = 1;
//PAUSED_KEY = 'pause-this-domain-pls-interactive-fics-yalla-bina';
const verbsHelper = requireDist();
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
if ('input_word' in message){
escapeAndReplace(message.input_word, message.replace_value, message.case_sensitive);
} else {
replaceAll();
}
});
function replaceAll() {
browser.storage.local.get(null, replaceAllInStorage); // TODO this is bad
}
function replaceAllInStorage(options) {
//const hostname = window.location.hostname
//const is_paused = options[PAUSED_KEY] && options[PAUSED_KEY].indexOf(hostname) !== -1
{ // change paused later to only care about hostname
replaceVerbs(options);
replaceName(options);
replacePronouns(options);
replacePov(options);
replacePlv(options);
replaceAlso(options);
}
}
function replaceName(options) {
const regexp = /\by\/n\b|\(y\/n\)|\[y\/n\]/ig;
walk(document.body, regexp, options["name"], directMethod);
}
function replaceVerbs(options) {
if (getPronouns(options.preset, options.other).plurality == "plural") {
const regexp = /([Pp])(?:rn|ov)\/S [Vv]rb\/([\w\s]+)\/([\w\s]+)\/|[Vv]rb\/([\w\s]+)\/([\w\s]+)\/ ([Pp])(?:rn|ov)\/S/;
walk(document.body, regexp, options, pluralThirdVerbMethod);
}
const regexp = /vrb\/([\w\s]+)\/([\w\s]+)\//;
walk(document.body, regexp, options, verbMethod);
}
// TODO case sensitivity, premade regexp
function replacePronouns(options) {
if (options.preset == "") { return; }
let pronouns = getPronouns(options.preset, options.other);
replacePronounSet("Prn/s", "prn/s", pronouns["subjective"]);
replacePronounSet("Prn/o", "prn/o", pronouns["objective"]);
replacePronounSet("Prn/p", "prn/p", pronouns["possessive"]);
replacePronounSet("Prn/a", "prn/a", pronouns["adjective"]);
replacePronounSet("Prn/r", "prn/r", pronouns["reflexive"]);
replacePronounSet("Prn/H", "prn/H", pronouns["honorific-abbr"]);
replacePronounSet("Prn/h", "prn/h", pronouns["honorific"]);
replacePronounSet("Prn/N", "prn/N", pronouns["noun-adult"]);
replacePronounSet("Prn/n", "prn/n", pronouns["noun-child"]);
}
function getPronouns(key, other) {
switch (key) {
case "she":
return {
"subjective": "she",
"objective": "her",
"possessive": "her",
"adjective": "hers",
"reflexive": "herself",
"honorific-abbr": "Ms.",
"honorific": "miss",
"noun-adult": "woman",
"noun-child": "girl",
"plurality": "singular"
};
case "he":
return {
"subjective": "he",
"objective": "him",
"possessive": "his",
"adjective": "his",
"reflexive": "himself",
"honorific-abbr": "Mr.",
"honorific": "mister",
"noun-adult": "man",
"noun-child": "boy",
"plurality": "singular"
};
case "they":
return {
"subjective": "they",
"objective": "them",
"possessive": "their",
"adjective": "theirs",
"reflexive": "themself",
"honorific-abbr": "Mx.",
"honorific": "mix",
"noun-adult": "person",
"noun-child": "kid",
"plurality": "plural"
};
case "first":
return {
"subjective": "I",
"objective": "me",
"possessive": "my",
"adjective": "mine",
"reflexive": "myself"
};
case "second":
return {
"subjective": "you",
"objective": "you",
"possessive": "your",
"adjective": "yours",
"reflexive": "yourself"
};
case "first-plural":
return {
"subjective": "we",
"objective": "us",
"possessive": "our",
"adjective": "ours",
"reflexive": "ourselves"
};
case "second-plural":
return {
"subjective": "you",
"objective": "you",
"possessive": "your",
"adjective": "yours",
"reflexive": "yourselves"
};
case "third-plural":
return {
"subjective": "they",
"objective": "them",
"possessive": "their",
"adjective": "theirs",
"reflexive": "themselves"
};
case "other":
return other;
}
}
function replacePronounSet(keyCapital, key, pronoun) {
if (pronoun === undefined) { return; }
escapeAndReplace(keyCapital, capitalize(pronoun), true);
escapeAndReplace(key, pronoun, true);
}
function replacePov(options) {
let pronouns;
switch (options.pov) {
case "":
return;
case "third":
pronouns = getPronouns(options.preset, options.other);
replacePronounSet("Pov/S", "pov/S", options.name);
replacePronounSet("Pov/O", "pov/O", options.name);
replacePronounSet("Pov/P", "pov/P", options.name + "'s");
replacePronounSet("Pov/A", "pov/A", options.name + "'s");
replacePronounSet("Pov/R", "pov/R", options.name + "'s self");
break;
default:
pronouns = getPronouns(options.pov, null);
replacePronounSet("Pov/S", "pov/S", pronouns["subjective"]);
replacePronounSet("Pov/O", "pov/O", pronouns["objective"]);
replacePronounSet("Pov/P", "pov/P", pronouns["possessive"]);
replacePronounSet("Pov/A", "pov/A", pronouns["adjective"]);
replacePronounSet("Pov/R", "pov/R", pronouns["reflexive"]);
}
replacePronounSet("Pov/s", "pov/s", pronouns["subjective"]);
replacePronounSet("Pov/o", "pov/o", pronouns["objective"]);
replacePronounSet("Pov/p", "pov/p", pronouns["possessive"]);
replacePronounSet("Pov/a", "pov/a", pronouns["adjective"]);
replacePronounSet("Pov/r", "pov/r", pronouns["reflexive"]);
}
function replacePlv(options) {
if (options.pov == "") { return; }
let pronouns = getPronouns(options.pov + "-plural", null);
replacePronounSet("Plv/s", "plv/s", pronouns["subjective"]);
replacePronounSet("Plv/o", "plv/o", pronouns["objective"]);
replacePronounSet("Plv/p", "plv/p", pronouns["possessive"]);
replacePronounSet("Plv/a", "plv/a", pronouns["adjective"]);
replacePronounSet("Plv/r", "plv/r", pronouns["reflexive"]);
}
function replaceAlso(options) {
Object.entries(options.also).forEach(([key, value]) => {
escapeAndReplace(key, value, true);
});
}
function escapeAndReplace(input_word, replace_value, case_sensitive) {
let input_word_escaped = input_word.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
const flags = case_sensitive ? "g" : "ig";
if (input_word_escaped[0].match(/[a-z]/i)) {
input_word_escaped = `\\b${input_word_escaped}`;
}
if (input_word_escaped[input_word_escaped.length - 1].match((/[a-z]/i))) {
input_word_escaped = `${input_word_escaped}\\b`;
}
const regexp_input_word = new RegExp(input_word_escaped, flags);
walk(document.body, regexp_input_word, replace_value, directMethod);
}
function walk(node, input_word, replace_value, replaceMethod) {
if (node.contentEditable == "true" || node.type == "textarea" || node.type == "input") { return; }
let child, next;
switch (node.nodeType) {
case 1: /* ELEMENT_NODE */
case 9: /* DOCUMENT_NODE */
case 11: /* DOCUMENT_FRAGMENT_NODE */
child = node.firstChild;
while (child) {
next = child.nextSibling;
walk(child, input_word, replace_value, replaceMethod);
child = next;
}
break;
case 3: /* TEXT_NODE */
replaceMethod(node, input_word, replace_value);
}
}
function directMethod(node, input_word, replace_value) {
node.nodeValue = node.nodeValue.replace(input_word, replace_value); // TODO might replaceall work better here?;
}
// TODO do something about options being not input_word
function verbMethod(node, regexp, options) {
let match = node.nodeValue.match(regexp);
if (match == null) { return; }
const verb = match[1];
const tense = match[2].toUpperCase().replaceAll(" ", "_");
const replace_value = verbsHelper.getConjugation(null, verb, tense, getPovIndex(options));
node.nodeValue = node.nodeValue.replace(regexp, replace_value);
verbMethod(node, regexp, options);
}
function pluralThirdVerbMethod(node, regexp, options) {
let match = node.nodeValue.match(regexp);
if (match == null) { return } const before = match[1];
match[4];
const wasBefore = !(before === undefined);
let verb, tense;
if (wasBefore) {
verb = match[2];
tense = match[3];
} else {
verb = match[5];
tense = match[6];
}
tense = tense.toUpperCase().replaceAll(" ", "_");
const replace_verb = verbsHelper.getConjugation(null, verb, tense, 2);
let replace_value;
if (wasBefore) {
replace_value = options["name"] + " " + replace_verb;
} else {
replace_value = replace_verb + " " + options["name"];
}
node.nodeValue = node.nodeValue.replace(regexp, replace_value);
pluralThirdVerbMethod(node, regexp, options);
}
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.slice(1);
}
// TODO figure out plv for this
function getPovIndex(options) {
switch (options.pov) {
case "first":
return 0;
case "second":
return 1;
case "third":
if (getPronouns(options.preset, options.other).plurality == "singular") {
return 2;
} else { /* Plurality is plural, "they go" */
return 5;
}
}
}
replaceAll();
return replaceWords$1;
}
var replaceWordsExports = requireReplaceWords();
var replaceWords = /*@__PURE__*/getDefaultExportFromCjs(replaceWordsExports);
module.exports = replaceWords;

View File

@ -1,52 +0,0 @@
:root {
--background-color: white;
--text-color: black;
--large-text: 16px;
--small-text: 14px;
}
body {
background-color: var(--background-color);
color: var(--text-color);
width: 350px; /* Same as width of add-on viewer on my system */
padding-left: 10px;
padding-right: 10px;
font-family: 'Inter', sans-serif;
font-size: var(--small-text);
margin: auto;
}
ul {
list-style: none;
padding-left: 0;
}
button {
display: flex;
justify-content: center;
align-items: center;
border: 0;
border-radius: 30px;
width: 100%;
font-size: var(--large-text);
padding: 6px;
margin-top: 6px;
margin-bottom: 6px;
gap: 8px;
text-align: center;
cursor: pointer;
}
button:hover {
transition-duration: 0.3s;
}
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

View File

@ -16,14 +16,14 @@
"browser_action": {
"default_title": "MetamorPOV",
"default_icon": {
"16": "img/mpov-16.png",
"32": "img/mpov-32.png",
"48": "img/mpov-48.png",
"64": "img/mpov-64.png",
"96": "img/mpov-96.png",
"128": "img/mpov-128.png"
"16": "img/metamorpov.svg",
"32": "img/metamorpov.svg",
"48": "img/metamorpov.svg",
"64": "img/metamorpov.svg",
"96": "img/metamorpov.svg",
"128": "img/metamorpov.svg"
},
"default_popup": "popup/popup.html"
"default_popup": "popup.html"
},
"permissions": [
@ -32,18 +32,18 @@
],
"icons": {
"16": "img/mpov-16.png",
"32": "img/mpov-32.png",
"48": "img/mpov-48.png",
"64": "img/mpov-64.png",
"96": "img/mpov-96.png",
"128": "img/mpov-128.png"
"16": "img/metamorpov.svg",
"32": "img/metamorpov.svg",
"48": "img/metamorpov.svg",
"64": "img/metamorpov.svg",
"96": "img/metamorpov.svg",
"128": "img/metamorpov.svg"
},
"content_scripts": [
{
"js": [
"replace-words-and-verbs.js"
"content-script.js"
],
"run_at": "document_idle",
"matches": [
@ -52,12 +52,8 @@
}
],
"options_ui": {
"page": "options/options.html"
},
"background": {
"page": "popup/popup.html"
"page": "popup.html"
},
"homepage_url": "https://git.viscogliosi-pate.com/jean/metamorpov"

View File

@ -1,113 +0,0 @@
// DEACTIVATE_KEY = 'deactivate-this-extension-pls-interactive-fics-yalla-bina';
//
// document.addEventListener('DOMContentLoaded', function () {
// // event listeners
// document.getElementById('change-name-form').addEventListener('submit', changeName)
// document.getElementById('replace-other-words-form').addEventListener('submit', replaceOther)
// document.getElementById('show-saved').addEventListener('click', loadSaved)
// document.getElementById('refresh-replacements').addEventListener('click', refreshReplacements)
// document.getElementById('enable-observer').addEventListener('click', toggleMutationObserver)
// document.getElementById('toggle').addEventListener('click', togglePauseDomain)
//
// // set settings buttons
// setMutationObserverKey()
// setPauseDomainKey()
// });
//
//
// const changeName = () => {
// const person = document.getElementById('change-name-form-text').value
// if (person) {
// chrome.storage.sync.set({'person': person}, chrome.tabs.reload())
// }
// }
//
// const refreshReplacements = () => {
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// chrome.tabs.sendMessage(
// tabs[0].id,
// {
// refresh: true
// })
// })
// }
//
// const loadSaved = () => {
// const list = document.getElementById('saved-items-list')
// list.innerHTML = ''
// chrome.storage.sync.get(null, loadSavedItemsWrapper(false))
// chrome.storage.local.get(null, loadSavedItemsWrapper(true))
// }
//
// const loadSavedItemsWrapper = isLocal => items => loadSavedItems(items, isLocal)
//
// const loadSavedItems = (items, isLocal) => {
// const list = document.getElementById('saved-items-list')
// for (var key in items) {
// if (key !== DEACTIVATE_KEY && key !== MUTATION_OBSERVER_KEY && key !== PAUSED_KEY && !key.endsWith('_case_sensitive')) {
// const label = key === 'person' ? 'Y/N' : key
// const case_sensitive = !!items[`${key}_case_sensitive`]
// const case_sensitive_string = case_sensitive ? 'case sensitive' : 'not case sensitive'
// const representative = `${label} -> ${items[key]} (${case_sensitive_string})`
// const list_item = createListItem(key, representative, 'one-saved-item', isLocal)
// list.appendChild(list_item)
// }
// }
// }
//
// const setPauseDomainKey = () => {
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// const hostname = new URL(tabs[0].url).hostname
// document.getElementById('this-url').innerHTML = hostname
//
// const storage_key = {}
// storage_key[PAUSED_KEY] = []
// chrome.storage.sync.get(storage_key, obj => {
// const hostnames = obj[PAUSED_KEY]
// const is_paused = hostnames.indexOf(hostname) !== -1
// togglePauseDomainLabel(is_paused)
//
// if (is_paused) {
// const other_elements = document.getElementsByClassName('fade-when-deactivate')
// const pause_only_other_elements = document.getElementsByClassName('fade-when-pause')
// Array.from([...other_elements, ...pause_only_other_elements]).forEach(element => {
// element.style.opacity = '0.5'
// })
// const input_elements = document.getElementsByTagName('INPUT')
// Array.from(input_elements).forEach(input => {
// if (input.id !== 'pause' && input.id !== 'deactivate') {
// input.disabled = 'disabled'
// }
// })
// }
// })
// })
// }
//
// const togglePauseDomain = () => {
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// const hostname = new URL(tabs[0].url).hostname
//
// const storage_key = {}
// storage_key[PAUSED_KEY] = []
// chrome.storage.sync.get(storage_key, obj => {
// const hostnames = obj[PAUSED_KEY]
// const was_paused = hostnames.indexOf(hostname) !== -1
// var new_hostnames;
//
// if (was_paused) {
// new_hostnames = hostnames.filter(h => h !== hostname)
// } else {
// new_hostnames = hostnames
// new_hostnames.push(hostname)
// }
//
// const new_obj = {}
// new_obj[PAUSED_KEY] = new_hostnames
// chrome.storage.sync.set(new_obj)
//
// chrome.tabs.reload()
// window.close()
// })
// })
// }

View File

@ -1,99 +0,0 @@
@import url("../global.css");
body {
height: 356px; /* Height of popup */
}
input {
border: 0;
border-radius: 30px;
font-size: var(--large-text);
padding: 2px 8px 2px 8px;
gap: 8px;
box-sizing: border-box;
width: 100%;
background-color: rgb(233, 233, 237);
}
select {
border: 0;
border-radius: 30px;
font-size: var(--large-text);
padding: 2px 2px 2px 8px;
gap: 8px;
}
label {
font-size: var(--large-text);
}
.primary-prompt {
display: flex;
align-items: center;
text-wrap: nowrap;
gap: 6px;
margin-top: 20px;
}
.primary-promt input {
font-size: 50px;
}
#other {
display: none; /* Modified by options.js */
gap: 6px;
margin-top: 12px;
margin-left: 18px;
}
#other li {
display: grid;
grid-template-columns: 1fr 2fr;
align-items: center;
gap: 6px;
}
#other > li > label {
font-size: var(--small-text);
text-align: right;
text-wrap: nowrap;
}
#other > li > input {
font-size: var(--small-text);
}
#other > li > select {
font-size: var(--small-text);
width: min-content;
}
#also > li {
display: flex;
align-items: center;
gap: 6px;
margin-top: 6px;
}
.lhs {
text-align: right;
}
#also > li > button {
background-color: transparent;
width: fit-content;
margin: 0;
padding: 0;
}
.hide-button > button {
visibility: hidden;
}
#button-grid {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 8px;
margin-top: 20px;
margin-bottom: 20px;
}

View File

@ -1,121 +0,0 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<link href='options.css' rel='stylesheet' type='text/css'>
<script src="options.js" type="text/javascript"></script>
</head>
<body>
<main>
<h1 class="visually-hidden">Options</h1>
<form id="options">
<h2 class="visually-hidden">Name</h2>
<div class="primary-prompt">
<label for="name">My name is</label>
<input type="text" id="name" name="name">
</div>
<h2 class="visually-hidden">Pronouns</h2>
<div class="primary-prompt">
<label for="preset">My pronouns are</label>
<select id="preset" name="preset">
<option value=""></option>
<option value="he">he/him</option>
<option value="she">she/her</option>
<option value="they">they/them</option>
<option value="other">other</option>
</select>
</div>
<ul id="other">
<li>
<label for="subjective">Subjective</label>
<input type="text" id="subjective" name="subjective" placeholder="e.g. he, they">
</li>
<li>
<label for="objective">Objective</label>
<input type="text" id="objective" name="objective" placeholder="e.g. her, them">
</li>
<li>
<label for="possessive">Possessive</label>
<input type="text" id="possessive" name="possessive" placeholder="e.g. his, their">
</li>
<li>
<label for="adjective">Adjective</label>
<input type="text" id="adjective" name="adjective" placeholder="e.g. hers, theirs">
</li>
<li>
<label for="reflexive">Reflexive</label>
<input type="text" id="reflexive" name="reflexive" placeholder="e.g. himself, themself">
</li>
<li>
<label for="honorific-abbr">Honorific abbr.</label>
<input type="text" id="abbr" name="honorific-abbr" placeholder="e.g. Ms., Mx.">
</li>
<li>
<label for="honorific">Honorific</label>
<input type="text" id="honorific" name="honorific" placeholder="e.g. mister, mix">
</li>
<li>
<label for="noun-adult">Adult noun</label>
<input type="text" id="adult" name="adult-noun" placeholder="e.g. woman, person">
</li>
<li>
<label for="noun-child">Child noun</label>
<input type="text" id="child" name="child-noun" placeholder="e.g. boy, kid">
</li>
<li>
<label for="plurality">Conjugates</label>
<select id="plurality" name="conjugates">
<option value="singular">singular</option>
<option value="plural">plural</option>
</select>
</li>
</ul>
<h2 class="visually-hidden">Perspective</h2>
<div class="primary-prompt">
<label for="pov">I prefer to read in</label>
<select id="pov" name="pov">
<option value=""></option>
<option value="first">first-person</option>
<option value="second">second-person</option>
<option value="third">third-person</option>
</select>
</div>
<h2 class="visually-hidden">Also replace</h2>
<label class="primary-prompt" for="lhs-1">I also want to replace...</label>
<ul id="also"></ul>
<div id="button-grid">
<button type="submit">
<img src="../img/save.svg" alt="">
Save
</button>
<button type="button" id="restore">
<img src="../img/restore.svg" alt="">
Restore
</button>
</div>
</form>
</main>
</body>
</html>

427
src/popup.css Normal file
View File

@ -0,0 +1,427 @@
/*TODO text color dropdowns, button icons and text*/
:root {
--font-features: "calt" 1, "case" 0, "ccmp" 1, "ss03" 1, "cv01" 1, "cv05" 1, "cv06" 1, "cv08" 0, "cv11" 1, "cv12" 0, "cv13" 0;
--large-text: 16px;
--small-text: 14px;
/* Grayscale */
--color-l-gray-10: hsla(36, 38%, 98%, 1);
--color-l-gray-20: hsla(35, 36%, 96%, 1);
--color-l-gray-30: hsla(35, 37%, 92%, 1);
--color-l-gray-40: hsla(34, 34%, 90%, 1);
--color-l-gray-50: hsla(36, 35%, 88%, 1);
--color-l-gray-60: hsla(37, 38%, 83%, 1);
--color-l-gray-70: hsla(34, 37%, 70%, 1);
--color-l-gray-80: hsla(34, 29%, 60%, 1);
--color-l-gray-90: hsla(31, 23%, 50%, 1);
--color-l-gray-100: hsla(35, 28%, 40%, 1);
--color-l-gray-110: hsla(34, 30%, 37%, 1);
--color-l-gray-120: hsla(36, 32%, 30%, 1);
--color-l-gray-130: hsla(31, 45%, 24%, 1);
--color-l-gray-140: hsla(33, 54%, 17%, 1);
--color-l-alpha-gray: hsla(34, 37%, 70%, 0.15);
--text-color: var(--color-l-gray-120);
--desc-color: var(--color-l-gray-100);
--placeholder-color: var(--color-l-gray-70);
--link-color: var(--color-l-gray-90);
--icon-color: var(--color-l-gray-80);
--icon-color-hover: var(--color-l-gray-90);
--border-color: var(--color-l-gray-50);
--border-color-hover: var(--color-l-gray-60);
--scrollbar-color: var(--color-l-gray-70);
--button-inset-shadow-size: 2px;
--shadow: inset 0px 1px 0px 0px rgba(255, 255, 255, 0.2),
inset 0px 0px 0px 1px rgba(0, 0, 0, 0.1),
inset 0px calc(-1 * var(--button-inset-shadow-size)) 0px 2px rgba(0, 0, 0, 0.09),
inset 0px -2px 4px 0px rgba(0, 0, 0, 0.1),
0px 4px 4px -5.6px rgba(0, 0, 0, 0.4),
0px 2px 4px -2.7px rgba(0, 0, 0, 0.1),
0px 2px 4px -1px rgba(0, 0, 0, 0.05);
--shadow-hover: inset 0px 1px 0px 0px rgba(255, 255, 255, 0.4),
inset 0px 0px 0px 1px rgba(0, 0, 0, 0.15),
inset 0px calc(-1 * var(--button-inset-shadow-size)) 0px 2px rgba(0, 0, 0, 0.09),
inset 0px -2px 4px 0px rgba(0, 0, 0, 0.1),
0px 4px 4px -5.6px rgba(0, 0, 0, 0.4),
0px 2px 4px -2.7px rgba(0, 0, 0, 0.15),
0px 2px 6px -1px rgba(0, 0, 0, 0.1);
--shadow-active: inset 0px 0px 0px 1px rgba(0, 0, 0, 0.15),
inset 0px 0px 0px calc(1px + var(--button-inset-shadow-size)) rgba(0, 0, 0, 0.09),
inset 0px 2px 8px 0px rgba(0, 0, 0, 0.2),
0px 0px 0px 1px rgba(255, 255, 255, 0.6);
--shadow-focus: inset 0px 1px 0px 0px rgba(255, 255, 255, 0.2),
inset 0px 0px 0px 1px rgba(0, 0, 0, 0.1),
inset 0px calc(-1 * var(--button-inset-shadow-size)) 0px 2px rgba(0, 0, 0, 0.09),
inset 0px -2px 4px 0px rgba(0, 0, 0, 0.1),
0px 4px 4px -5.6px rgba(0, 0, 0, 0.4),
0px 2px 4px -2.7px rgba(0, 0, 0, 0.1),
0px 2px 4px -1px rgba(0, 0, 0, 0.05),
0px 0px 0px 3px var(--color-l-alpha-gray);
--text-input-shadow-active: inset 0px 1px 0px 0px rgba(255, 255, 255, 1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.04), 0px 1px 6px 0px rgba(0, 0, 0, 0.07);
}
input, select {
background-color: var(--color-l-gray-20);
border: 1px solid var(--border-color);
border-radius: .5em;
font-size: var(--large-text);
color: var(--text-color);
padding: 2px 8px 2px 8px;
gap: 8px;
}
input {
box-sizing: border-box;
width: 100%;
}
input::placeholder {
color: var(--placeholder-color);
}
input:hover {
border: 1px solid var(--border-color-hover);
transition: 0.3s;
}
input:focus {
transition: 0.1s;
border: 1px solid var(--border-color-hover);
background-color: var(--color-l-gray-10);
box-shadow: var(--text-input-shadow-active);
outline: none;
}
select {
padding: 6px;
box-shadow: var(--shadow);
}
select:active {
transition: 0.1s;
box-shadow: var(--shadow-active);
}
select:focus {
box-shadow: var(--shadow-focus);
}
label {
font-size: var(--large-text);
}
.primary-prompt {
display: flex;
align-items: center;
text-wrap: nowrap;
gap: 6px;
margin-top: 20px;
}
.primary-promt input {
font-size: 50px;
}
#other {
display: none; /* Modified by options.js */
gap: 6px;
margin-top: 12px;
margin-left: 18px;
}
#other li {
display: grid;
grid-template-columns: 1fr 2fr;
align-items: center;
gap: 6px;
}
#other > li > label {
font-size: var(--small-text);
text-align: right;
text-wrap: nowrap;
}
#other > li > input {
font-size: var(--small-text);
}
#other > li > select {
font-size: var(--small-text);
width: min-content;
}
#also > li {
display: flex;
align-items: center;
gap: 6px;
margin-top: 6px;
}
.lhs {
text-align: right;
}
#also > li > button {
background-color: transparent;
width: fit-content;
margin: 0;
padding: 0;
}
.hide-button > button {
visibility: hidden;
}
body {
background-color: var(--color-l-gray-30);
color: var(--text-color);
width: 350px; /* Same as width of add-on viewer on my system */
height: 500px; /* Max height allowed TODO verify on wi-fi */
padding-left: 10px;
padding-right: 15px;
font-family: 'Inter', sans-serif;
font-feature-settings: var(--font-features);
font-size: var(--small-text);
margin: auto;
}
html {
scrollbar-color: var(--scrollbar-color) transparent;
}
ul {
list-style: none;
padding-left: 0;
}
/* Button grid */
#button-grid {
display: grid;
grid-template-columns: 7fr 5fr;
gap: 8px;
margin-top: 20px;
margin-bottom: 20px;
}
#button-grid > button {
display: flex;
justify-content: center;
align-items: center;
font-weight: 600;
border: 1px solid var(--border-color);
border-radius: .5em;
width: 100%;
font-size: var(--large-text);
padding: 6px;
margin-top: 6px;
margin-bottom: 6px;
gap: 8px;
text-align: center;
cursor: pointer;
box-shadow: var(--shadow);
}
#button-grid > button > svg {
width: 24px;
height: 24px;
transform: translateY(-10%);
}
#button-grid > button > p {
margin: 0;
font-family: 'Inter', sans-serif;
font-feature-settings: var(--font-features);
transform: translateY(-10%);
}
#button-grid > button:hover {
transition-duration: 0.3s;
box-shadow: var(--shadow-hover);
}
#button-grid > button:active {
transition: 0.3s;
box-shadow: var(--shadow-active);
}
#button-grid > button:active > p {
transition: 0.3s;
transform: translateY(0%);
}
#button-grid > button:active > svg {
transition: 0.3s;
transform: translateY(0%);
}
/* Save button */
#save {
background-color: var(--color-l-gray-90);
color: var(--color-l-gray-10);
}
#save:hover {
background-color: var(--color-l-gray-80);
}
#save:active {
background-color: var(--color-l-gray-90);
}
/* Restore button */
#restore {
background-color: var(--color-l-gray-20);
color: var(--text-color);
}
#restore:hover {
background-color: var(--color-l-gray-10);
}
#restore:active {
background-color: var(--color-l-gray-20);
}
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
/* Site enabled section */
#site-enabled {
display: none; /* TODO Actually do this section! */
grid-template-columns: 2fr 1fr;
background-color: var(--color-l-gray-10);
padding: 10px;
border: 0;
border-radius: .5em;
}
#hostname {
font-size: var(--large-text);
font-weight: 400;
text-align: center;
}
#site-enabled svg {
width: 50%;
justify-self: center;
align-self: center;
cursor: pointer;
}
/* Configuration section */
#configuration {
background-color: var(--color-l-gray-10);
padding: 10px;
border: 0;
border-radius: .5em;
margin-top: var(--small-text);
}
label {
font-size: var(--large-text);
}
.primary-promt input {
font-size: 50px;
}
#other {
display: none; /* Modified by options.js */
gap: 6px;
margin-top: 12px;
margin-left: 18px;
}
#other li {
display: grid;
grid-template-columns: 1fr 2fr;
align-items: center;
gap: 6px;
}
#other > li > label {
font-size: var(--small-text);
text-align: right;
text-wrap: nowrap;
}
#other > li > input {
font-size: var(--small-text);
}
#other > li > select {
font-size: var(--small-text);
width: min-content;
}
#also > li {
display: flex;
align-items: center;
gap: 6px;
margin-top: 6px;
}
.lhs {
text-align: right;
}
#also > li > button {
color: var(--icon-color);
background-color: transparent;
width: 24px;
height: 24px;
margin: 0;
padding: 0;
border: 0;
box-shadow: 0;
}
#also > li > button:hover {
color: var(--icon-color-hover);
}
.hide-button > button {
visibility: hidden;
}
/* Links section */
#links {
text-align: right;
}
#links > li {
margin-top: 6px;
}
a {
color: var(--link-color);
text-decoration: underline;
text-underline-offset: 2px;
transition-duration: 0.3s;
}
a:hover{
color: var(--text-color);
}

133
src/popup.html Normal file
View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<link href='popup.css' rel='stylesheet' type='text/css'>
<script src="popup.js" type="text/javascript"></script>
</head>
<body>
<main>
<div id="site-enabled">
<h1 id="hostname">mycoolsite.com</h1>
<!--<p>Enable the site bla bla</p>-->
<img src="img/toggle-on.svg" alt="Toggle to disable"/>
</div>
<div id="configuration">
<form id="options">
<h2 class="visually-hidden">Name</h2>
<div class="primary-prompt">
<label for="name">My name is</label>
<input type="text" id="name" name="name">
</div>
<h2 class="visually-hidden">Pronouns</h2>
<div class="primary-prompt">
<label for="preset">My pronouns are</label>
<select id="preset" name="preset">
<option value=""></option>
<option value="he">he/him</option>
<option value="she">she/her</option>
<option value="they">they/them</option>
<option value="other">other</option>
</select>
</div>
<ul id="other">
<li>
<label for="subjective">Subjective</label>
<input type="text" id="subjective" name="subjective" placeholder="e.g. he, they">
</li>
<li>
<label for="objective">Objective</label>
<input type="text" id="objective" name="objective" placeholder="e.g. her, them">
</li>
<li>
<label for="possessive">Possessive</label>
<input type="text" id="possessive" name="possessive" placeholder="e.g. his, their">
</li>
<li>
<label for="adjective">Adjective</label>
<input type="text" id="adjective" name="adjective" placeholder="e.g. hers, theirs">
</li>
<li>
<label for="reflexive">Reflexive</label>
<input type="text" id="reflexive" name="reflexive" placeholder="e.g. himself, themself">
</li>
<li>
<label for="honorific-abbr">Honorific abbr.</label>
<input type="text" id="abbr" name="honorific-abbr" placeholder="e.g. Ms., Mx.">
</li>
<li>
<label for="honorific">Honorific</label>
<input type="text" id="honorific" name="honorific" placeholder="e.g. mister, mix">
</li>
<li>
<label for="noun-adult">Adult noun</label>
<input type="text" id="adult" name="adult-noun" placeholder="e.g. woman, person">
</li>
<li>
<label for="noun-child">Child noun</label>
<input type="text" id="child" name="child-noun" placeholder="e.g. boy, kid">
</li>
<li>
<label for="plurality">Conjugates</label>
<select id="plurality" name="conjugates">
<option value="singular">singular</option>
<option value="plural">plural</option>
</select>
</li>
</ul>
<h2 class="visually-hidden">Perspective</h2>
<div class="primary-prompt">
<label for="pov">I prefer to read in</label>
<select id="pov" name="pov">
<option value=""></option>
<option value="first">first-person</option>
<option value="second">second-person</option>
<option value="third">third-person</option>
</select>
</div>
<h2 class="visually-hidden">Also replace</h2>
<label class="primary-prompt" for="lhs-1">I also want to replace...</label>
<ul id="also"></ul>
<div id="button-grid">
<button type="submit" id="save">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"/><path d="M7 3v4a1 1 0 0 0 1 1h7"/></svg>
<p>Save</p>
</button>
<button type="button" id="restore">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/></svg>
<p>Restore</p>
</button>
</div>
</form>
</div>
</main>
<ul id="links">
<li><a href="https://git.viscogliosi-pate.com/jean/metamorpov/wiki" target="_blank">How to write for MetamorPOV</a></li>
<li><a href="mailto:metamorpov@viscogliosi-pate.com" target="_blank">Report an issue</a></li>
<li><a href="https://git.viscogliosi-pate.com/jean/metamorpov" target="_blank">Source code</a></li>
</ul>
</body>
</html>

View File

@ -121,10 +121,8 @@ function createLi(index) {
const button = document.createElement("button");
button.type = "button";
const buttonImg = document.createElement("img");
buttonImg.src = "../img/delete.svg";
buttonImg.alt="Clear fields";
button.append(buttonImg);
button.id = "delete";
button.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z\"/><path d=\"m12 9 6 6\"/><path d=\"m18 9-6 6\"/></svg>";
button.addEventListener("click", removeLi);
li.append(lhs);

View File

@ -1,54 +0,0 @@
@import url("../global.css");
#hostname {
font-size: var(--large-text);
font-weight: 400;
text-align: center;
}
#display-enabled {
display: grid;
grid-template-columns: 1fr 2fr;
}
#display-enabled img {
width: 50%;
justify-self: center;
align-self: center;
cursor: pointer;
}
#display-enabled h2 {
font-size: var(--large-text);
font-weight: 400;
margin-right: 15%;
}
#display-features {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
text-align: center;
}
#display-features img {
width: 50%;
}
#display-features p {
margin-top: 0;
}
ul {
text-align: right;
}
a{
color: var(--text-color);
text-decoration: none;
transition-duration: 0.3s;
}
a:hover{
text-decoration: underline;
}

View File

@ -1,54 +0,0 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<link href='popup.css' rel='stylesheet' type='text/css'>
<script src="popup.js" type="text/javascript"></script>
</head>
<body>
<main>
<h1 id="hostname">TODO</h1>
<div id="display-enabled">
<img id="toggle" src="../img/toggle-on.svg" alt="Toggle"/>
<h2>MetamorPOV is <b>TODO</b> for this website</h2>
</div>
<div id="display-features">
<div id="yn-usage">
<img src="../img/check.svg" alt="Check"/>
<p>Y/n is used on this page</p>
</div>
<div id="prn-usage">
<img src="../img/check.svg" alt="Check"/>
<p>prn/ is used on this page</p>
</div>
<div id="pov-usage">
<img src="../img/check.svg" alt="Check"/>
<p>pov/ is used on this page</p>
</div>
</div>
</main>
<a href="../options/options.html">
<button id="configure">
<img src="../img/configure.svg" alt=""/>
Configure name, pronouns, and POV
</button>
</a>
<button id="refresh">
<img src="../img/refresh.svg" alt=""/>
Refresh replacements
</button>
<ul class="links">
<li><a href="https://git.viscogliosi-pate.com/jean/metamorpov/wiki" target="_blank">How to write for MetamorPOV</a></li>
<li><a href="mailto:metamorpov@viscogliosi-pate.com" target="_blank">Report an issue</a></li>
<li><a href="https://git.viscogliosi-pate.com/jean/metamorpov" target="_blank">Source code</a></li>
</ul>
</body>
</html>

View File

@ -1,214 +0,0 @@
// DEACTIVATE_KEY = 'deactivate-this-extension-pls-interactive-fics-yalla-bina';
// MUTATION_OBSERVER_KEY = 'observe-this-dom-pls-interactive-fics-yalla-bina';
//
//
// document.addEventListener('DOMContentLoaded', function () {
// // event listeners
// document.getElementById('change-name-form').addEventListener('submit', changeName)
// document.getElementById('replace-other-words-form').addEventListener('submit', replaceOther)
// document.getElementById('show-saved').addEventListener('click', loadSaved)
// document.getElementById('refresh-replacements').addEventListener('click', refreshReplacements)
// document.getElementById('enable-observer').addEventListener('click', toggleMutationObserver)
// document.getElementById('toggle').addEventListener('click', togglePauseDomain)
//
// // set settings buttons
// setMutationObserverKey()
// setPauseDomainKey()
// });
//
//
// const changeName = () => {
// const person = document.getElementById('change-name-form-text').value
// if (person) {
// chrome.storage.sync.set({'person': person}, chrome.tabs.reload())
// }
// }
//
// const replaceOther = () => {
// const input_word = document.getElementById('replace-word').value
// const replacement = document.getElementById('replace-with').value
// const is_case_sensitive = document.getElementById('is-case-sensitive').checked
// if (input_word && replacement) {
// if (document.getElementById('is-perm').checked) {
// const obj = {}
// obj[input_word] = replacement
// obj[`${input_word}_case_sensitive`] = is_case_sensitive
// chrome.storage.sync.set(obj)
// }
//
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// chrome.tabs.sendMessage(
// tabs[0].id,
// {
// input_word: input_word,
// replace_value: replacement,
// case_sensitive: is_case_sensitive
// })
// })
// }
// }
//
// const refreshReplacements = () => {
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// chrome.tabs.sendMessage(
// tabs[0].id,
// {
// refresh: true
// })
// })
// }
//
// const loadSaved = () => {
// const list = document.getElementById('saved-items-list')
// list.innerHTML = ''
// chrome.storage.sync.get(null, loadSavedItemsWrapper(false))
// chrome.storage.local.get(null, loadSavedItemsWrapper(true))
// }
//
// const loadSavedItemsWrapper = isLocal => items => loadSavedItems(items, isLocal)
//
// const loadSavedItems = (items, isLocal) => {
// const list = document.getElementById('saved-items-list')
// for (var key in items) {
// if (key !== DEACTIVATE_KEY && key !== MUTATION_OBSERVER_KEY && key !== PAUSED_KEY && !key.endsWith('_case_sensitive')) {
// const label = key === 'person' ? 'Y/N' : key
// const case_sensitive = !!items[`${key}_case_sensitive`]
// const case_sensitive_string = case_sensitive ? 'case sensitive' : 'not case sensitive'
// const representative = `${label} -> ${items[key]} (${case_sensitive_string})`
// const list_item = createListItem(key, representative, 'one-saved-item', isLocal)
// list.appendChild(list_item)
// }
// }
// }
//
// const createListItem = (id, text, className, isLocal) => {
// const text_node = document.createTextNode(text)
// const list_node = document.createElement('LI')
// list_node.appendChild(text_node)
// list_node.className = className
// list_node.id = id
// list_node.addEventListener('click', () => {
// if (isLocal) {
// chrome.storage.local.remove(id)
// } else {
// chrome.storage.sync.remove(id)
// }
// list_node.className += ' strikethrough'
// })
// return list_node
// }
//
//
// const setDeactivateKey = () => {
// chrome.storage.sync.get(DEACTIVATE_KEY, obj => {
// const is_deactivated = obj[DEACTIVATE_KEY]
// toggleDeactivateLabel(is_deactivated)
//
// if (is_deactivated) {
// const other_elements = document.getElementsByClassName('fade-when-deactivate')
// const deactivate_only_elements = document.getElementsByClassName('fade-when-deactivate-only')
// Array.from([...other_elements, ...deactivate_only_elements]).forEach(element => {
// element.style.opacity = '0.5'
// })
// const input_elements = document.getElementsByTagName('INPUT')
// Array.from(input_elements).forEach(input => {
// if (input.id !== 'deactivate') {
// input.disabled = 'disabled'
// }
// })
// }
// })
// }
//
// const setMutationObserverKey = () => {
// chrome.storage.sync.get(MUTATION_OBSERVER_KEY, obj => {
// const is_enabled = obj[MUTATION_OBSERVER_KEY]
// toggleMutationObserverLabel(is_enabled)
// })
// }
//
// const setPauseDomainKey = () => {
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// const hostname = new URL(tabs[0].url).hostname
// document.getElementById('this-url').innerHTML = hostname
//
// const storage_key = {}
// storage_key[PAUSED_KEY] = []
// chrome.storage.sync.get(storage_key, obj => {
// const hostnames = obj[PAUSED_KEY]
// const is_paused = hostnames.indexOf(hostname) !== -1
// togglePauseDomainLabel(is_paused)
//
// if (is_paused) {
// const other_elements = document.getElementsByClassName('fade-when-deactivate')
// const pause_only_other_elements = document.getElementsByClassName('fade-when-pause')
// Array.from([...other_elements, ...pause_only_other_elements]).forEach(element => {
// element.style.opacity = '0.5'
// })
// const input_elements = document.getElementsByTagName('INPUT')
// Array.from(input_elements).forEach(input => {
// if (input.id !== 'pause' && input.id !== 'deactivate') {
// input.disabled = 'disabled'
// }
// })
// }
// })
// })
// }
//
// const toggleDeactivateLabel = (isDeactivated) => {
// document.getElementById('deactivate').checked = isDeactivated;
//
// }
//
// const toggleMutationObserverLabel = (isEnabled) => {
// document.getElementById('enable-observer').checked = isEnabled;
// }
//
// const togglePauseDomainLabel = (isPaused) => {
// document.getElementById('pause').checked = isPaused;
// }
//
// const toggleMutationObserver = () => {
// chrome.storage.sync.get(MUTATION_OBSERVER_KEY, obj => {
// const was_enabled = obj[MUTATION_OBSERVER_KEY]
//
// if (was_enabled) {
// chrome.storage.sync.remove(MUTATION_OBSERVER_KEY)
// } else {
// const new_object = {}
// new_object[MUTATION_OBSERVER_KEY] = true
// chrome.storage.sync.set(new_object)
// }
//
// chrome.tabs.reload()
// })
// }
//
// const togglePauseDomain = () => {
// chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// const hostname = new URL(tabs[0].url).hostname
//
// const storage_key = {}
// storage_key[PAUSED_KEY] = []
// chrome.storage.sync.get(storage_key, obj => {
// const hostnames = obj[PAUSED_KEY]
// const was_paused = hostnames.indexOf(hostname) !== -1
// var new_hostnames;
//
// if (was_paused) {
// new_hostnames = hostnames.filter(h => h !== hostname)
// } else {
// new_hostnames = hostnames
// new_hostnames.push(hostname)
// }
//
// const new_obj = {}
// new_obj[PAUSED_KEY] = new_hostnames
// chrome.storage.sync.set(new_obj)
//
// chrome.tabs.reload()
// window.close()
// })
// })
// }