summaryrefslogtreecommitdiff
path: root/qutebrowser/browser/greasemonkey.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/browser/greasemonkey.py')
-rw-r--r--qutebrowser/browser/greasemonkey.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/qutebrowser/browser/greasemonkey.py b/qutebrowser/browser/greasemonkey.py
index 03db3be0c..7fea5820c 100644
--- a/qutebrowser/browser/greasemonkey.py
+++ b/qutebrowser/browser/greasemonkey.py
@@ -67,6 +67,7 @@ class GreasemonkeyScript:
self.runs_on_sub_frames = True
self.jsworld = "main"
self.name = ''
+ self.dedup_suffix = 1
for name, value in properties:
if name == 'name':
@@ -104,6 +105,20 @@ class GreasemonkeyScript:
def __str__(self):
return self.name
+ def full_name(self) -> str:
+ """Get the full name of this script.
+
+ This includes a GM- prefix, its namespace (if any) and deduplication
+ counter suffix, if set.
+ """
+ parts = ['GM-']
+ if self.namespace is not None:
+ parts += [self.namespace, '/']
+ parts.append(self.name)
+ if self.dedup_suffix > 1:
+ parts.append(f"-{self.dedup_suffix}")
+ return ''.join(parts)
+
@classmethod
def parse(cls, source, filename=None):
"""GreasemonkeyScript factory.