Created
April 25, 2017 19:19
-
-
Save noromanba/e5020682a9dc6ade06a019615425c7cd to your computer and use it in GitHub Desktop.
scroll into changed flags on Chrome/mium for Devtools Console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @name next +flag | |
// @namespace http://noromanba.flavors.me | |
// @description scroll into changed flags on Chrome/mium for Devtools Console | |
// @include chrome://flags/* | |
// @version 2017.4.25.1 | |
// @homepage https://gist.github.com/noromanba/e5020682a9dc6ade06a019615425c7cd | |
// @license MIT License https://nrm.mit-license.org/2017 | |
// @author noromanba http://noromanba.flavors.me | |
// view all changed flags below, see "Command Line" section | |
// chrome://version/ | |
(() => { | |
'use strict'; | |
Array.from(document.body.querySelectorAll([ | |
'.experiment-switched' | |
])).some(switched => { | |
const feature = new URL(switched.querySelector([ | |
'a[href].permalink' | |
]).href).hash; | |
// http://let.hatelabo.jp/noromanba/let/hLHWrt-tvNtK | |
// current scrolling values | |
// window.scrollY | |
// window.pageYOffset | |
// document.documentElement.scrollTop | |
// document.body.scrollTop | |
const absPos = Math.trunc(switched.getBoundingClientRect().top | |
+ document.body.scrollTop); | |
if (location.hash === feature || | |
absPos <= document.body.scrollTop) { | |
return; | |
} | |
location.hash = feature; | |
return true; | |
// TBD back to #top when scroll to last/bottom | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment