Skip to content

Commit ae5f41e

Browse files
author
hoang.tran12
committed
flash title - wip
1 parent 2ca29db commit ae5f41e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/content-scripts/scripts/ufs_global_webpage_context.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ const UsefulScriptGlobalPageContext = {
2828
},
2929
},
3030
DOM: {
31+
// https://stackoverflow.com/a/3381522
32+
createFlashTitle(newMsg, howManyTimes) {
33+
var original = document.title;
34+
var timeout;
35+
36+
function step() {
37+
document.title = document.title == original ? newMsg : original;
38+
if (--howManyTimes > 0) {
39+
timeout = setTimeout(step, 1000);
40+
}
41+
}
42+
howManyTimes = parseInt(howManyTimes);
43+
if (isNaN(howManyTimes)) {
44+
howManyTimes = 5;
45+
}
46+
clearTimeout(timeout);
47+
step();
48+
49+
function cancel() {
50+
clearTimeout(timeout);
51+
document.title = original;
52+
}
53+
54+
return cancel;
55+
},
56+
3157
deleteElements(selector, willReRun) {
3258
UsefulScriptGlobalPageContext.onElementsVisible(
3359
selector,

0 commit comments

Comments
 (0)