User:Surjection/plus-mode.js

var g = ["1st_person","2nd_person","3rd_person","AD","AHD","BC","BCE","CE","CJKV","IPA","Imitative","Katharevousa","Kulturwort","OED","POS","Plural","PoS","Portmanteau","Romanisation","Romanization","SAMPA","SGV","Singular","Sino-Xenic","UK","Unadapted_borrowing","Uncountable","Univerbation","X-SAMPA","a.","abbreviation","ablative","ablative_case","ablaut","absolutive","absolutive_case","abstract","abstract_noun","abstract_verb","acc.","accusative","accusative_case","acronym","active","active_voice","acute","acute_accent","adjective","adstrate","adstratum","adverb","adverbial","adverbial_clause","af","affix","agent_noun","agent_nouns","agentive","alternative_form","ambitransitive","ambitransitive_verb","analogy","anglicisation","anglicised","anglicization","anglicized","angry_register","animacy","animate","antepenult","antepenultima","antepenultimate","antonym","antonymous","aorist","aorist_tense","aphaeresis","aphaeretic","apheresis","apheretic","aphesis","aphetic","apocopate","apocopated","apocopation","apocope","apocopic","approximant","archaic","archaism","areal","areal_feature","article","aspect","aspirated_h","assimilate","assimilated","assimilation","atelic","atelic_verb","attributive","attributively","augment","augmentative","augmented","autonym","auxiliary","auxiliary_verb","avoidance","back-formation","back_vowel","backronym","backslang","bahuvrihi","barytone","blend","borrowed","borrowing","bound_form","bowdlerization","broad","broadly","c","c.","ca.","calque","calqued","case","category","catenative","catenative_verb","causative","causative_verb","cf.","circumlocutory","classifier","clause","clipping","clitic","cognate","coinage","coined","collective","collective_noun","collectively","colloquial","common","common_gender","comparable","comparative","compound","concrete","concrete_noun","concrete_verb","conditional","conditional_mood","conjugation","conjunction","conjunctive","connegative","consonant","consonantism","construct_state","contamination","contracted","contraction","contranym","conversion","coordinate_term","coordinative","copula","copulative","corruption","countable","counter","culture_word","dat","dated","dative","dative_case","declension","defective","defective_spelling","definite","degrees_of_comparison","denominal","dependent","dependent_clause","deponent","derived_terms","derogatory","descendants","descriptive","desiderative","determinate","determinate_verb","determinative","determiner","deverbal","diachronic","diachronically","diachrony","diacope","diacritic","diacritical","diacritical_mark","diaeresis","dialectal","diaresis","dieresis","diminutive","direct_object","displaced","dissimilate","dissimilated","dissimilation","ditransitive","ditransitive_verb","doublet","dual","dual_number","dummy_pronoun","dvandva","dysphemism","ed.","elative","elative_case","elided","elision","ellipsis","elongated","emphatic","enPR","enclisis","endocentric","endonym","epenthesis","epenthetic","epicene","eponym","eponymous","equative","equivalent_to","ergative","ergative_case","ergative_verb","etymology","etymon","euphemism","excessive_spelling","excrescent","exocentric","exonym","expletive","eye_dialect","eye_spelling","ezafe","f","factitive","factitive_verb","false_cognate","false_friend","familiar","feminine","figurative","first-person","first_person","fl.","focus","folk_etymological","folk_etymologies","folk_etymology","formal","fossil","fossil_word","fossilised","fossilized","fpl","frequentative","fricative","front_vowel","future","future_perfect","future_tense","gemination","gender","gender-neutral","gender_neutral","genericized_trademark","genitive","genitive_case","gerund","ghost_word","government","grade","grammatical_number","grammatical_object","grammatical_person","grave","grave_accent","habitual","hapax","hapax_legomenon","haplological","haplology","hedge","higher_register","historical","holonym","homograph","homophone","hot_word","humorous","hyperbole","hyperbolic","hypercorrect","hypercorrection","hyperforeign","hyperforeignism","hypernym","hyperthesis","hyperthetic","hyphenation","hyponym","ideophone","ideophonic","idiom","idiomatic","imitative","imparisyllabic","imperative","imperative_mood","imperfect","imperfective","imperfective_aspect","imperfective_past","impersonal","impersonal_verb","inanimate","indeclinable","indefinite","independent_clause","indeterminate","indeterminate_verb","indicative","indicative_mood","indirect_object","infinitive","infix","inflected","inflection","inflectional","informal","inherited","initialism","inline_reference","ins","instrumental","instrumental_case","intensifier","intensifying","interfix","interjection","internationalism","intransitive","intransitive_verb","invariable","invariant","iotation","irregular","iterative","jussive","jussive_mood","karmadharaya","kenning","learned_borrowing","lemma","letter_case","lexeme","liaison","ligature","linking_verb","literally","literary","litotes","loan","loan_blend","loan_translation","loanblend","loanword","loc","locative","locative-qualitative","locative-qualitative_case","locative_case","loose","loosely","loosely_speaking","m","macron","masculine","mass_noun","measure_word","mediopassive","meiosis","men's_speech","meronym","metanalysis","metaphor","metaphorical","metathesis","metathesise","metathesised","metathesize","metathesized","metathetic","metonym","metonymic","metonymical","metonymically","middle-voice","middle_voice","minced_oath","mixed","mixed_declension","monolectic","monosyllable","mood","morpheme","mpl","multiword_expression","multiword_phrase","mute_h","n","narrow","narrowly","nasal_infix","negative_polarity","negative_polarity_item","negative_verb","neologism","neuter","nominal","nominalisation","nominalization","nominative","nominative_case","non-finite","non-past","non-past_tense","nonce","nonce_word","nonfinite","nonstandard","nonvirile","noun","noun_class","noun_clause","number","object","objective","objective_case","oblique","oblique_case","obs","obsolete","offensive","onomatopoeia","onomatopoeic","optative_mood","orthographic_borrowing","outdated","oxytone","oxytonic","p.","palatalization","palindrome","paradigm","paragoge","paragogic","parisyllabic","paroxytone","part_of_speech","partial_calque","partially_calqued","participial","participle","participles","particle","partitive","partitive_case","passive","passive_voice","past","past_historic","past_perfect","past_tense","pejorative","penult","penultima","perfect","perfective","perfective_aspect","periphrastic","person","phoneme","phono-semantic_compound","phono-semantic_matching","phrase","piecewise_doublet","pl","pl.","plosive","pluperfect","plural","plural_number","plural_only","plurale_tantum","pluralia_tantum","polylectic","popular_etymology","portmanteau","positive","positive_polarity","positive_polarity_item","possessional_adjective","possessive_adjective","possessive_determiner","postposition","postpositive","preconsonantal","predicate","predicative","predicatively","prefix","prefixation","prefixed","preposition","prepositional","prepositional_case","prescriptive","present","present_tense","preterite","preterite-present_verb","prevocalic","privative_adjective","productive","progressive","pronominal","pronominal_verb","pronoun","pronunciation_spelling","proparoxytone","proper_noun","proscribed","prothesis","protologism","proverb","pseudo-acronym","pseudo-anglicism","pseudo-loan","pseudoacronym","pseudoanglicism","rare","reanalysed","reanalysis","reanalyzed","rebracketing","reciprocal","reconstructed","reconstruction","rection","reducible","reduplicated","reduplication","reflex","reflexive","register","related_terms","relational","relational_adjective","relative","relative_clause","respelled","respelling","retronym","rhetoric","rhetorical_question","rhotacism","rhotacization","romanisation","romanization","root","s","s.l.","s.n.","script","second-person","second-person-object","second-person-object_form","second_person","second_person_object","semantic_loan","semelfactive","semi-learned_borrowing","semivowel","sentence","sentence_adverb","set_expression","set_phrase","sg","sg.","short_form","shortening","sic","siglum","simile","simplex","singular","singular_number","singulative","singulative_number","slang","slavic_first_palatalization","slavic_progressive_palatalization","snowclone","solemn","sound-symbolic","sound_change","sound_symbolism","spelling_pronunciation","stem","strate","stratum","strict","strictly","strong_conjugation","strong_declension","strong_pronoun","strong_verb","subject","subjunctive","subjunctive_mood","subordinate_clause","substantive","substantivisation","substantivization","substrate","substratum","suffix","suffixed","superlative","superseded","superstrate","superstratum","supine","suppletion","suppletive","surface","surface_analysis","surface_etymology","syllable","synchronic","synchronically","synchrony","syncopated","syncopation","syncope","syncopic","syncretic","syncretism","synonym","tashif","tatpurusa","tautology","technical","telic","telic_verb","tense","thematicization","third-person","third_person","tmesis","tone","topicalized","toponym","tr.","tran.","transferred_sense","transferred_senses","transgressive","transitive","transitive_verb","transl.","translation_hub","transliteration","transnumeral","transnumeral_number","troponym","twice-borrowed","umlaut","unadapted_borrowing","uncommon","uncomparable","uncountable","undeclinable","univerbation","usage_notes","var.","varia_lectio","variae_lectiones","variant","variant_reading","velar","verb","verbal_noun","verbs","verlan","virile","vocative","vocative_case","voice","voiced","voiceless","voicing","vowel","vulgar","wanderword","wanderwort","weak_declension","weak_pronoun","weak_verb","women's_speech","zero-grade","zero_grade","ʾiʿrāb","ʾiḍāfa"];

function prefix(a,b){ let i = 0; while(a[i] && a[i] == b[i]) i++; return a.slice(0, i); }

function longest_prefix(arr,s) { var t='',m=-1; for (var i=0;im) { t=p,m=n; } }  return t; }

jQuery(document).ready(function($){   $('.ns-0 #mw-content-text').find('*').each(function { $(this).contents.filter(function {    return this.nodeType === 3;  }).replaceWith(function {      return this.nodeValue.replace(/\b([A-Za-z0-9-]+)\b/g, function (a) { return '\001' + longest_prefix(g,a.toLowerCase) + '\002' + a + '\003'; });  }); }); document.body.innerHTML=document.body.innerHTML.replace(/\001(.+?)\002(.+?)\003/g, '$2'); });