This Firefish Plugin allows you to highlight a word or simple phrase in your feed to grab your attention. It adds a background an an optional sparkle effect to the phrase. A single word or short phrase works best.
Overview
Firefish Plugins are a great way to customize your experience on the platform.
I created this plugin to gain an understanding of how AiScript works, and Firefish Plugins in general. It’s not perfect, but it’s useful and a bit of fun.
Those interested in learning AiScript may find it useful as a learning tool. Take a look at the code and see how it works!
New to plugins? Check out my earlier post here, which goes into detail about what plugins are and how to install them.
Settings
The plugin has a few settings you can configure to customize your experience.
By default, there isn’t Search Term entered, so there won’t be an effect on your timeline. You’ll need to enter a word or short phrase in the Search Term field to see the effect.
NOTE: If your Firefish instance is running version v13.1.4.1 or lower, you’ll need to enable Compatibility Mode. This is enabled by default. If your Firefish instance is running any custom mods, this plugin may not work as expected.
Setting | Description |
---|---|
Search Phrase | The word or short phrase you want to highlight. |
Compatibility Mode | Color effects don’t work on older versions of Calckey. Enabled by default. |
Background Color | |
Text Color | |
Sparkle Effect | Toggle the sparkle effect on the highlighted phrase. |
Debug Mode | For developers, shows messages in the console. |
Installation
If you’re on a Firefish server, you can install this plugin by copying the code below into the Settings > Plugins section. You can read more about installing plugins here or watch a video demonstration of the process here.
Hope you find it useful! More plugins coming soon.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/// @ 0.11.1
### {
name: "Highlighter"
version: "0.11.1.0.001"
author: "@[email protected]"
description: "Highlight a word or short phrase found in a note on your timelines. View settings to change the phrase, set colors, and enable or disable the sparkle effect."
permissions: []
config: {
searchTerm: {
type: "string"
label: "Search Phrase"
description: "Required. A word or short phrase that will be highlighted and sparkled on your timelines when found."
default: ""
}
enableCompatibilityMode: {
type: "boolean"
label: "Compatibility Mode"
description: "Enabled by default. Firefish instances running version v13.1.4.1 or lower do not have MFM foreground and background properties, which causes a display issue."
default: yes
}
bgColor: {
type: "string"
label: "Background Color"
description: "The HEX code you want to use for the background color of the search phrase. Requires Firefish version v13.2.0.0 beta or higher."
default: "D8D7B0"
}
fgColor: {
type: "string"
label: "Text Color"
description: "Required. The HEX code you want to use for the text color of the search phrase. Requires Firefish version v13.2.0.0 beta or higher."
default: "31748F"
}
enableSparkle: {
type: "boolean"
label: "Sparkle Effect"
description: "Enable sparkle effect on search phrases."
default: yes
}
debug: {
type: "boolean"
label: "Enable Debugging"
description: "Write debugging information to the console."
default: no
}
}
}
@debug(comment) {
? (Plugin:config.debug = yes) {
$_comment <- comment
_comment <- Arr:join(["Plugin: Highlighter: " _comment])
print(comment)
}
}
#c = {}
c.searchTerm <- Plugin:config.searchTerm
c.bgColor <- Plugin:config.bgColor
c.fgColor <- Plugin:config.fgColor
c.enableSparkle <- Plugin:config.enableSparkle
c.enableCompatibilityMode <- Plugin:config.enableCompatibilityMode
? (c.bgColor = "") {
c.bgColor <- "D8D7B0"
}
? (c.fgColor = "") {
c.fgColor <- "31748F"
}
c.bgColor <- Str:replace(c.bgColor, "#", "")
c.fgColor <- Str:replace(c.fgColor, "#", "")
// The term effect is just a code pattern I use. It's not required.
// I break my code into handler and effect functions to make it easier to read and debug.
@effect(note) {
? (c.searchTerm != "") {
debug("Search Term Exists 🕵🏾♀️")
$noteText <- ""
? Core:eq(note.text, _) {
noteText <- ""
} . {
noteText <- note.text
}
$wordReplacement <- ""
#noteUpper = Str:upper(noteText)
? (Str:index_of(noteUpper, Str:upper(c.searchTerm)) > 0) {
debug("Search Term Found")
? (c.enableSparkle = yes) {
debug("✨ Starting Sparkles")
wordReplacement <- " $[sparkle "
}
? (c.enableCompatibilityMode = yes) {
debug("Using Code instead of Colors")
wordReplacement <- Arr:join([wordReplacement "$[x2 ` " c.searchTerm " ` ]"])
} . {
debug("Applying Colors")
wordReplacement <- Arr:join([wordReplacement "$[x2 $[bg.color=" c.bgColor " $[fg.color=" c.fgColor " " c.searchTerm " ]]]"])
}
? (c.enableSparkle = yes) {
debug("✨ Finishing Sparkles")
wordReplacement <- Arr:join([wordReplacement "]"])
}
debug("📚 Defining Search Term Derivatives")
#wordReplacementHash = Str:replace(wordReplacement, c.searchTerm, Arr:join(["#" c.searchTerm]))
#searchTerm = Str:lower(c.searchTerm)
#searchTermLower = Str:lower(c.searchTerm)
#searchTermUpper = Str:upper(c.searchTerm)
#searchTermFirstUpper = Arr:join([Str:upper(Str:slice(c.searchTerm, 1, 2)) Str:lower(Str:slice(c.searchTerm, 2, (Str:len(c.searchTerm) + 1)))])
#searchTermHashUpper = Arr:join(["#" Str:upper(c.searchTerm)])
debug("🔖 Highlighting Search Term")
noteText <- Str:replace(noteText, c.searchTerm, searchTermUpper)
noteText <- Str:replace(noteText, searchTermLower, searchTermUpper)
noteText <- Str:replace(noteText, searchTermFirstUpper, searchTermUpper)
noteText <- Str:replace(noteText, Arr:join([":" searchTermUpper ":"]), searchTermLower)
noteText <- Str:replace(noteText, searchTermHashUpper, wordReplacementHash)
noteText <- Str:replace(noteText, Arr:join([" " searchTermUpper]), wordReplacement)
noteText <- Str:replace(noteText, searchTermUpper, wordReplacement)
debug("🎉 Returning updated note text")
debug(noteText)
note.text <- noteText
}
}
note
}
// The term handler is just my own code pattern. You can use whatever you want.
@handler(note_) {
debug("Begin Handler")
// Apply this effect not only to the main note, but any replies or renotes as well.
$note <- effect(note_)
? Obj:has(note, "renote") { note.renote <- effect(note.renote) }
? Obj:has(note, "reply") { note.reply <- effect(note.reply) }
debug("End Handler")
note
}
Plugin:register_note_view_interruptor(handler)
Comments
Total Interactions: 19Likes
Posts, Re-Posts and Bookmarks
Replies
Tonight I'm introducing a new Calckey Plugin (my first release)!
The Highlighter Plugin will take a specific word or short phrase and highlight it throughout your timelines. You can customize the colors and turn a sparkle effect off or on.