Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5958668
speculationRules.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
speculationRules.js
View Options
/* eslint-disable camelcase */
/**
* Initializes the Speculation Rules API for Citizen
*
* @return {void}
*/
function
init
()
{
if
(
!
HTMLScriptElement
.
supports
||
!
HTMLScriptElement
.
supports
(
'speculationrules'
)
)
{
return
;
}
const
articlePath
=
mw
.
config
.
get
(
'wgArticlePath'
).
replace
(
/\$(1)/
,
''
);
const
namespaces
=
mw
.
config
.
get
(
'wgFormattedNamespaces'
);
if
(
!
articlePath
||
!
namespaces
)
{
return
;
}
const
specRules
=
{
prerender
:
[
{
where
:
{
and
:
[
{
href_matches
:
`
${
articlePath
}
*`
},
// Under article path
{
href_matches
:
`
${
articlePath
}${
namespaces
[
-
1
]
}
`
},
// No special namespace
{
not
:
{
href_matches
:
'/.*.php'
}
},
// Not PHP file
{
not
:
{
href_matches
:
'/*\\?*(^|&)*=*'
}
},
// No query strings
{
not
:
{
selector_matches
:
'[rel~=nofollow]'
}
}
// No nofollow link
]
},
eagerness
:
'moderate'
}
]
};
const
specScript
=
document
.
createElement
(
'script'
);
specScript
.
type
=
'speculationrules'
;
specScript
.
textContent
=
JSON
.
stringify
(
specRules
);
document
.
body
.
append
(
specScript
);
}
module
.
exports
=
{
init
:
init
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 3, 05:56 (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
52/06/a655c79c7c2a640f992396d371ed
Default Alt Text
speculationRules.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment