-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub_sticky_editor_header.user.js
More file actions
46 lines (43 loc) · 1.73 KB
/
github_sticky_editor_header.user.js
File metadata and controls
46 lines (43 loc) · 1.73 KB
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
// ==UserScript==
// @name Github Sticky Editor Header
// @namespace https://github.com/StaticPH
// @match http*://github.com/*/*/edit/*
// include /https?:\/\/github\.com\/[^\/]+\/[^\/]+\/edit\/.+\.(md|MD|Md|adoc|asciidoc|rst)/
// @version 1.0.1
// @createdAt 11/24/2021, 1:50:21 AM
// @author StaticPH
// @description Makes the header of the (text) file editor on GitHub sticky.
// @description Nice for when you are frequently switching between edit and preview while editing in the middle of a long document.
// @license MIT
// @updateURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/github_sticky_editor_header.user.js
// @downloadURL https://raw.githubusercontent.com/StaticPH/Userscripts/master/github_sticky_editor_header.user.js
// @homepageURL https://github.com/StaticPH/UserScripts
// @supportURL https://github.com/StaticPH/UserScripts/issues
// @icon https://github.githubassets.com/pinned-octocat.svg
// @grant GM.addStyle
// @grant GM_addStyle
// @run-at document-idle
// ==/UserScript==
(function(){
"use strict";
// Prefer asychronous Greasemonkey4-API GM.addStyle, but allow use of GM_addStyle as a fallback if necessary.
if (typeof GM === 'undefined'){
this.GM = {};
}
if (GM['addStyle'] === undefined){
console.log('GM.addStyle is not defined. Falling back to GM_addStyle Promise.');
GM['addStyle'] = function(...args){
return new Promise((onResolve, onReject) => {
try{ onResolve(GM_addStyle.apply(this, args)); }
catch(err){ onReject(err); }
});
}
}
GM.addStyle(`
.js-code-editor.container-preview > .file-header {
top: 0%;
z-index: 100;
position: sticky;
}
`);
})();