Dev: Add timestamp to url when refresh #3
This commit is contained in:
@@ -17,7 +17,7 @@ Browse it on your phone: [http://liriliri.github.io/eruda/](http://liriliri.gith
|
||||
In order to try it for different sites, execute the script below on browser address bar.
|
||||
|
||||
```javascript
|
||||
javascript:(function () { var script = document.createElement('script'); script.src="//liriliri.github.io/eruda/eruda.min.js"; document.body.appendChild(script); script.onload=function () { eruda.init() } })();
|
||||
javascript:(function () { var script = document.createElement('script'); script.src="//liriliri.github.io/eruda/eruda.min.js"; document.body.appendChild(script); script.onload = function () { eruda.init() } })();
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
@@ -24,8 +24,20 @@ export default [
|
||||
name: 'Refresh Page',
|
||||
fn: function ()
|
||||
{
|
||||
window.location.reload();
|
||||
var url = window.location.href;
|
||||
|
||||
window.location.replace(query(url, 'timestamp', util.now()));
|
||||
},
|
||||
desc: 'Refresh current page'
|
||||
desc: 'Add timestamp to url and refresh'
|
||||
}
|
||||
];
|
||||
|
||||
function query(uri, key, val)
|
||||
{
|
||||
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"),
|
||||
separator = uri.indexOf('?') !== -1 ? "&" : "?";
|
||||
|
||||
if (uri.match(re)) return uri.replace(re, '$1' + key + "=" + val + '$2');
|
||||
|
||||
return uri + separator + key + "=" + val;
|
||||
}
|
||||
Reference in New Issue
Block a user